Posted February 8 '10 at 09:25 AM
Posts: 160
Hi,
Im having some issues with a search querey that is using pagination and a WHERE clause.
If I just use the querey without the WHERE clause it works fine:
$sql = "SELECT * FROM admin ORDER BY $orderby ASC LIMIT $start_from, $display_no";
$rs_result = mysql_query ($sql, $conn);
but if I add the WHERE clause in:
$sql = "SELECT * FROM admin ORDER BY $orderby WHERE $table_name = '$search_term' ASC LIMIT $start_from, $display_no";
$rs_result = mysql_query ($sql, $conn);
I get this error:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/fhlinux129/m/mysql.atumstudios.com/user/htdocs/backend/logged/admin_search_records.php on line 109
Any ideas?
I've tried moving the WHERE clause around the statement but seem to get the same error.
I did try removing the pagination part of the code and keeping the WHERE clause and that seemed to work its just getting them both to work together.
Sorry if this should be in the SQL forum.