turbocueca Posted April 11, 2006 Share Posted April 11, 2006 [b]A code that works:[/b][code]<form method="POST" action="">Search Word: <input type="text" name="query"><input type="SUBMIT" value="Search!"></form><?include 'db.php';if (isset($_POST['query'])) {$result = mysql_query("SELECT name,system FROM usbextreme WHERE name LIKE '%$query%'") or die (mysql_error());while(list($column1, $column2)=mysql_fetch_array($result)){echo "Result: $column1, $column2 <br />";}}?>[/code][b]My code:[/b][code]<form method="POST" action=""> Search:<input type="text" name="query"> <input type="SUBMIT" value="Search!"></form><?php if (isset($_POST['query'])) { include 'db.php'; $execute=mysql_query("SELECT name,system,work_status,postedby,comments FROM usbextreme WHERE name LIKE '%query%'") or die (mysql_error()); while (list($name,$sys,$stat,$user,$comment)=mysql_fetch_array($execute)) { echo "$name $sys $stat $user $comment"; } } else { echo "You didn't press the button!"; }?>[/code]Can someone please tell me what's wrong with my code, 'cause it doesn't search anything. Link to comment https://forums.phpfreaks.com/topic/7144-cant-search-mysql-db/ Share on other sites More sharing options...
turbocueca Posted April 12, 2006 Author Share Posted April 12, 2006 problem solved, had '%query%' instead of '%$query%' Link to comment https://forums.phpfreaks.com/topic/7144-cant-search-mysql-db/#findComment-26124 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.