I was writing some code for a webpage a couple of years ago, and I was pretty sure the following query worked. But, I got pulled away, and just started working on it again. But, for some reason the following line is not working. I have a simple search box at the top of the database output table. If a user enters in a search term, it will reload the same page, but cut the query down. But, I am getting an error with the following query line:
$sname = $_POST['sname'];
$qry="SELECT * FROM main_forms WHERE type = 'Form' ";
if($sname != "") {
$qry.="WHERE description LIKE '%$sname%' ";
}
$qry.="ORDER BY date_up desc, description";
The error I get is:
Error in executing stmt
error:1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE description LIKE '%notice%' ORDER BY date_up desc, descri
Any help would be appreciated.
Thanks,
Jeff