Jump to content

Archived

This topic is now archived and is closed to further replies.

fncuis

All Results Returned

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.