Re: [PHP-DB] Simple search engine gone bad
Hi Jennifer, >if($searchword = $iname) try it with a double equals sign if($searchword == $iname) >{ >echo "CELLSPACING='0'>"; >echo "$user"; >echo "$iname"; >echo "$q"; >echo "$price"; >echo ""; >} >} -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Simple search engine gone bad
Jenn, Get rid of 'value=\"\"' in your code and give it a shot again... Gurhan -Original Message- From: Jennifer Downey [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 9:32 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Simple search engine gone bad Hi all, It's Monday, it's probably something stupid, but I have poured over this all day and cannot find the problem. This is a simple search engine based on one table. It is suppose to return the results of the search word. Instead it returns ALL records in the mysql table. If I type the letter x and there are no words in the table with an x I still get all records returned. Would someone be kind enough to show me what I have done wrong. if($search) { $query = "SELECT iname, quantity, user, price FROM {$config["prefix"]}_shop WHERE iname LIKE '%$searchword%' AND price > 0 ORDER BY price"; $ret = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($ret)) { $user = $row['user']; $iname = $row['iname']; $q = $row['quantity']; $price = $row['price']; if($searchword = $iname) { echo ""; echo "$user"; echo "$iname"; echo "$q"; echo "$price"; echo ""; } } }else{ echo ""; echo "Search Shops"; echo ""; } Thank you Jennifer -- The sleeper has awaken --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Simple search engine gone bad
> > if($search) > { > $query = "SELECT iname, quantity, user, price FROM > {$config["prefix"]}_shop WHERE iname LIKE '%$searchword%' AND price > 0 Try putting $searchword within single quotes. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Simple search engine gone bad
Hi all, It's Monday, it's probably something stupid, but I have poured over this all day and cannot find the problem. This is a simple search engine based on one table. It is suppose to return the results of the search word. Instead it returns ALL records in the mysql table. If I type the letter x and there are no words in the table with an x I still get all records returned. Would someone be kind enough to show me what I have done wrong. if($search) { $query = "SELECT iname, quantity, user, price FROM {$config["prefix"]}_shop WHERE iname LIKE '%$searchword%' AND price > 0 ORDER BY price"; $ret = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($ret)) { $user = $row['user']; $iname = $row['iname']; $q = $row['quantity']; $price = $row['price']; if($searchword = $iname) { echo ""; echo "$user"; echo "$iname"; echo "$q"; echo "$price"; echo ""; } } }else{ echo ""; echo "Search Shops"; echo ""; } Thank you Jennifer -- The sleeper has awaken --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php