Thanks Kirk,
Actually it is working to a degree, the query variables are passed from original db search to a degree. I am new at this, I did not take into consideration of the database being open to a security risk from just a query. What would be the best way to implement sessions?
Here is a sample of what I have so far on the results page, the search page just refers to this with form input for 4 or 5 queried fields.
Thanks,
James
<?php
$server = "localhost";
$user = " ";
$pass = " ";
$database = " ";
$conn = mysql_pconnect ($server,$user,$pass);
$select = mysql_select_db("$database")or die ("unable to select db");
// Start of Prev 123 Next code
$limit=10; // rows to return
$numresults=mysql_query("select * "."from TABLE
WHERE Class_1 LIKE '%$Class_1%'
AND Class_2 LIKE '%$Class_2%'
AND Class_3 LIKE '%$Class_3%'
AND Class_4 LIKE '%$Class_4%'
AND Cat_No LIKE '%$Cat_No%'
AND Name LIKE '%$Name%'
AND Description LIKE '%$Description%'
AND Specials LIKE '%$Specials%'
order by 1,20");
$numrows=mysql_num_rows($numresults);
// next determine if offset has been passed to script, if not use 0
if (empty($offset))
{
$offset=0;
}
// get results
$result=mysql_query("select * "."from TABLE
WHERE Class_1 LIKE '%$Class_1%'
AND Class_2 LIKE '%$Class_2%'
AND Class_3 LIKE '%$Class_3%'
AND Class_4 LIKE '%$Class_4%'
AND Cat_No LIKE '%$Cat_No%'
AND Name LIKE '%$Name%'
AND Description LIKE '%$Description%'
AND Specials LIKE '%$Specials%'
"."order by 1,20 limit $offset,$limit");
// now you can display the results returned
if ($row=mysql_fetch_array($result)){
// include code to display results as you see fit
do {
print ("
Output.....
");
} while($row = mysql_fetch_array($result));
} else {print "<b>Sorry, no records were found!</b>";}
$query = "Class_3=$Class_3";
$query .= "&Class_4=$Class_4";
$query .= "&Name=$Name";
$query .= "&Description=$Description";
$query .= "&Specials=$Specials";
// calculate number of pages needing links
$pages=intval($numrows/$limit);
print "<br><table width=600 cellspacing=1 cellpadding=2 border=0><tr><td BGCOLOR=#FBF5E7><font face=arial size=1><b> Search Result Pages ";
// next we need to do the links to other results
if (($pages!=0 and $pages!=1) or ($pages==1 and ($numrows%$limit)))// If data <= 1 page skip all
{
if ($offset!=0)// bypass PREV link if offset is 0
{
$prevoffset=$offset-$limit;
echo "<a href=\"$PHP_SELF?$query&offset=$prevoffset\">PREV</a> \n";
}
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit)// has remainder so add one page
{
$pages++;
}
for ($i=1;$i<=$pages;$i++) // loop thru and make links
{
$newoffset=$limit*($i-1);
If ($offset!=$newoffset) //Make a link only for other pages
{
echo "<a href=\"$PHP_SELF?$query&offset=$newoffset\">$i</a> \n";
}
else
{
print "$i \n";
}
}
// check to see if NEXT link is needed
if ($pages!=1 or (($pages==1 and ($numrows%$limit))))
{
if (($offset+$limit)<$numrows) // if last page skip NEXT link
{$newoffset=$offset+$limit;
echo "<a href=\"$PHP_SELF?$query&offset=$newoffset\">NEXT</a><p>\n";
}
}
}
print "</b></font></td></tr></table>";
?>