Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Help me plz

Links for php scripts

Moderators: macek, egami, gesf

Help me plz

Postby spluskhan » Fri Mar 08, 2013 3:23 am

suppose i have 10 products in my database
Example:
iphone 2 - iphone 3g - laptop i3 - laptop i7 - nokia n96 etc

when i enter iphone in my search i see all records stored in database thats my prob!

what i want ?
suppose if i enter laptop i7 or laptop then i get result for laptop i7 or laptop

here is my code..
Code: Select all
<?php
// Connects to your Database
mysql_connect("host.com", "userr", "pass") or die(mysql_error());
mysql_select_db("products") or die(mysql_error()); [/font][/color]
[color=#000000][font=verdana, geneva, lucida,]$data = mysql_query("SELECT * FROM Products")
or die(mysql_error());
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th>Name:</th> <td>".$info['name'] . "</td> ";
Print "<th>new:</th> <td>".$info['new_price'] . "</td> ";
Print "<th>old:</th> <td>".$info['old_proce'] . "</td> ";
Print "<th>faulty:</th> <td>".$info['Faulty_price'] . " </td></tr>";
}
Print "</table>";
?>


if any one have better code then please give me tankxx
spluskhan
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sun Mar 03, 2013 4:33 am

Re: Help me plz

Postby spluskhan » Fri Mar 08, 2013 4:31 am

any bdy
spluskhan
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sun Mar 03, 2013 4:33 am

Re: Help me plz

Postby spluskhan » Fri Mar 08, 2013 6:18 am

hello any bdy
spluskhan
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sun Mar 03, 2013 4:33 am

Re: Help me plz

Postby seandisanti » Fri Mar 08, 2013 10:47 am

Breathe, man. lol. On this forum a response the same day is timely, especially in one of the lesser traveled sections like this. Your issue is that you're not filtering out your results at all with a WHERE statement. Here's an example video using PDO (much faster and more secure than the mysql functions you're currently using) it's short and should give you enough of a glimpse at PDO and sql to be able to use both for your purpose http://jream.com/learning/videos/php-oo ... o-examples
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron