Hello,
I am wondering how to do two things:
how can I get my script so that it displays the right numbers when it gets to the last page and there is only say 12 on the last page, I have it working that it shows the start record number and I have it add whatevery the results per page is.
also if it finds no results then it needs to show 0 to 0 for the numbers but right now it says 1 to 20 (20 is the default for results per page)
ok, the next question is how can I have the time that it toke to run the query display in sec?
below is the code:
search_display.php
<?php
if(empty($_GET['sq'])) // if there is no ?sq=... whatever then this displays
{
include '/home/dev/www/qna/search_form.php';
include '/home/dev/www/qna/qna_common.php';
}
else // if there is ?sq=... whatever then this displays
{
include '/home/dev/www/lib/page_nav_bar.php';
include '/home/dev/www/qna/search_form.php';
$searchquery = $_GET['sq'];
if(isset($_GET["pn"]))
{ $pagenumber = $_GET["pn"]; } else { $pagenumber = 1; }
if(isset($_GET["rpp"]))
{ $recordsperpage = $_GET["rpp"]; } else { $recordsperpage = 20; }
include '/home/dev/www/search/lib/db_config_ro-dev.php';
include '/home/dev/www/search/lib/db_conn-select.php';
$offset = ceil(($pagenumber - 1) * $recordsperpage);
$sql_a = " SELECT SQL_CALC_FOUND_ROWS * FROM query WHERE pno LIKE '%$searchquery%' LIMIT $offset, $recordsperpage";
$results_a = mysql_query($sql_a) OR die("Was unable to get the results!" . mysql_error());
$sql_b = "SELECT FOUND_ROWS()";
$results_b = mysql_query($sql_b);
$totalrecords = mysql_result($results_b, 0);
echo "<center>" . page_bar($searchquery, $totalrecords, $pagenumber) . "</center>";
$dsn = $offset + 1;
$den = $offset + $recordsperpage;
$process_time = '0.01 Sec';
echo "Your search for $searchquery found $totalrecords displaying $dsn to $den ($process_time)<br /><br />";
while ($row = mysql_fetch_array($results_a))
{
$ein = $row['EIN'];
$pno = $row['PNO'];
$state = $row['State'];
$ntee_code = $row['NTEE_Code'];
$activity_code = $row['Activity_Code'];
$sn = $row['SN_SNL'];
echo $pno ." -- ".$state." -- ".$ein."<br />";
echo $ntee_code ." -- ". $activity_code ." -- ". $sn ."<br /><br />";
}
echo "<center>" . page_bar($searchquery, $totalrecords, $pagenumber) . "</center>";
include '/home/dev/www/lib/db_close.php';
} // close the else statement for displaying the search box with results
?>
Thanks for the assistance with this question
Sincerely,
Christopher