fncuis Posted September 28, 2004 Share Posted September 28, 2004 Hello again, I created a search query that should only return results that are like the one entered in the "search field" of the search page. However, when ever i enter any value in the search field it returns all records in my table. Here is my SQL statement: <?php $currentPage = $_SERVER["PHP_SELF"]; $maxRows_rs1 = 50; $pageNum_rs1 = 0; if (isset($_GET['pageNum_rs1'])) { $pageNum_rs1 = $_GET['pageNum_rs1']; } $startRow_rs1 = $pageNum_rs1 * $maxRows_rs1; $sterm_rs1 = "1"; if (isset($_GET['sterm'])) { $sterm_rs1 = (get_magic_quotes_gpc()) ? $_GET['sterm'] : addslashes($_GET['sterm']); } mysql_select_db($database_msds, $msds); $query_rs1 = sprintf("SELECT * FROM msds WHERE msds.`ref` LIKE 'stermterm%%' OR msds.description LIKE '%%%s%%' OR msds.manufacturer LIKE '%%%%s%%' ORDER BY msds.`ref`ASC", $sterm_rs1); $query_limit_rs1 = sprintf("%s LIMIT %d, %d", $query_rs1, $startRow_rs1, $maxRows_rs1); $rs1 = mysql_query($query_limit_rs1, $msds) or die(mysql_error()); $row_rs1 = mysql_fetch_assoc($rs1); if (isset($_GET['totalRows_rs1'])) { $totalRows_rs1 = $_GET['totalRows_rs1']; } else { $all_rs1 = mysql_query($query_rs1); $totalRows_rs1 = mysql_num_rows($all_rs1); } $totalPages_rs1 = ceil($totalRows_rs1/$maxRows_rs1)-1; ?> Any ideas how to filter down? All the best, -F Quote Link to comment Share on other sites More sharing options...
morpheus.100 Posted September 28, 2004 Share Posted September 28, 2004 $maxRows_rs1 = 50; Alter the figure above. This determines the dynamic limit. Quote Link to comment Share on other sites More sharing options...
fncuis Posted September 29, 2004 Author Share Posted September 29, 2004 Max Rows allows me to specify how many records are displayed per page before the viewer hits next. I have a 170 records, all records get returned. Thanks, -F Quote Link to comment Share on other sites More sharing options...
morpheus.100 Posted September 30, 2004 Share Posted September 30, 2004 f (isset($_GET['totalRows_rs1'])) { $totalRows_rs1 = $_GET['totalRows_rs1']; } else { $all_rs1 = mysql_query($query_rs1); $totalRows_rs1 = mysql_num_rows($all_rs1); Then your error must be in the above. Echo total rows after this snippet to see if it is present. 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.