Jump to content


Photo

All Results Returned


  • Please log in to reply
3 replies to this topic

#1 fncuis

fncuis
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 28 September 2004 - 07:53 PM

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

#2 morpheus.100

morpheus.100
  • Members
  • PipPipPip
  • Advanced Member
  • 145 posts

Posted 28 September 2004 - 09:24 PM

$maxRows_rs1 = 50;

Alter the figure above. This determines the dynamic limit.

#3 fncuis

fncuis
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 29 September 2004 - 12:19 PM

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

#4 morpheus.100

morpheus.100
  • Members
  • PipPipPip
  • Advanced Member
  • 145 posts

Posted 30 September 2004 - 08:31 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users