tet3828 Posted November 7, 2006 Share Posted November 7, 2006 >:( I swear this query was working a little while ago. Any suggestions as to why a search would yeild no results when I know for sure the posted form value for %descvalue is in my database?? $qry = "SELECT itemName,itemId,itemPrice,itemSmall FROM `products` WHERE itemDesc OR itemName OR itemId like \"%$descvalue%\""; $result = mysql_query($qry) or die(mysql_error()); $amount = mysql_num_rows($result); echo "<br /><b><a href='http://claireart.net/shell/data/index.php'>Click Here</a></b> to try a different search.<br /><br /> ";while($row = mysql_fetch_array($result)) { echo "<table border=\"1\"><tr><td>".$row['itemName']."</td></tr>"; echo "<tr><td><center><img src=\"".$row['itemSmall']."\" /></center></td>"; echo "</tr><tr><td>Price: $".$row['itemPrice']."</td>"; echo "</tr>"; echo "<tr><td>"; echo "<a href=/shell/data/edit.php?id=".$row['itemId']." />Edit This Item</a>"; echo "</td></tr>"; echo "<br>"; echo "<br>";}echo "</table>"; Quote Link to comment Share on other sites More sharing options...
btherl Posted November 7, 2006 Share Posted November 7, 2006 That query syntax looks suspicious.. I would parse it as[code]SELECT itemName,itemId,itemPrice,itemSmallFROM `products`WHERE itemDesc IS TRUEOR itemName IS TRUEOR itemId like "%$descvalue%"[/code]Not sure about the double quotes, since i'm a postgres user. But I'm pretty sure that you need to specify the condition for every column to be checked.If it's still not making sense, try printing the query to the browser, then run it in phpmyadmin (or whichever interface you have for mysql) Quote Link to comment Share on other sites More sharing options...
tet3828 Posted November 7, 2006 Author Share Posted November 7, 2006 That last suggestion didn't quite do the trick. I even double checked to see if the descvalue was passed properly.anymore suggestions as to why this query would yeild no results?$qry = "SELECT itemName,itemId,itemPrice,itemSmall FROM `products` WHERE itemDesc OR itemName OR itemId LIKE \"%$descvalue%\""; Quote Link to comment Share on other sites More sharing options...
tet3828 Posted November 7, 2006 Author Share Posted November 7, 2006 ***bump*** sorry still unsolved. ??? Quote Link to comment Share on other sites More sharing options...
btherl Posted November 7, 2006 Share Posted November 7, 2006 I don't think I was clear. What I mean is this:[code]SELECT itemName,itemId,itemPrice,itemSmallFROM `products`WHERE itemDesc like "%$descvalue%"OR itemName like "%$descvalue%"OR itemId like "%$descvalue%"[/code]Do you want to check if $descvalue is in any of those 3 columns? Quote Link to comment Share on other sites More sharing options...
oracle259 Posted November 7, 2006 Share Posted November 7, 2006 i think the last post should work but i would make the following modification[code]SELECT itemName,itemId,itemPrice,itemSmallFROM `products`WHERE itemDesc like "%$descvalue%"OR (itemName like "%$descvalue%"OR itemId like "%$descvalue%")[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.