I want to search through a simple picture database and have the results returned in a paginated format. I have stumbled through getting the search to return what I desired (is this called tokenizing or parsing? or what?) Now I want the returned items (from the search) to be in a paginated format, that is show only 12 (or 9 or whatever the user chooses) per page.
here is most of my search part.
//getting data from search page
$find= $GET["find"];// keywords desired
$in= $GET["in"];// table column to search in
$logic= $GET["logic"];//do I use OR or AND
$sort= $GET["sort"];// eventually used to order the list returned
$fill= $_GET["fill"];// How many results to place on a page (default = 12)
$find = trim($find);//clean up the data a bit
@mysql_connect($hostname, $username, $password) or die("ERROR--CAN'T CONNECT TO SERVER");
@mysql_select_db($dbName) or die("ERROR--CAN'T CONNECT TO DB");
$findarray = explode(" ",$find);
if(!$findarray){$findarray='%';}
else {
$query = "SELECT * FROM $usertable WHERE $in LIKE '%$findarray[0]%' ";
if ($logic == 'or') {
For ($i=1; $i<count($findarray); $i++) {
$query .= "OR $in LIKE '%$findarray[$i]%' ";
} //end for
}
else {
For ($i=1; $i<count($findarray); $i++) {
$query .= "AND $in LIKE '%$findarray[$i]%' ";
} //end for
}
} // end if else
$result = mysql_query($query) or die("Error: " . mysql_error());
if(mysql_num_rows($result) == 0){
echo("Nothing to Display!");
}
echo("<table width='100%' border ='0' cellspacing ='5' cellpadding='5' align='center'>");
$x=0; //for page format
while($row = mysql_fetch_array($result)){
if ($x ==3) {
print ("<tr>");
$x=0;
}
print ("<td>");
print ("<div align = 'center'>");
print ("<a href='singlephoto.html?photoid=$row[0]'><img width='188' src='../photopages/photos/$row[0].jpg'></a>");
print ("<br>");
print ("$row[1]"); print ("<br>");
print ("<img width ='66' src='images/spacer.gif'>");
print ("</div>");
print ("<td>");
$x++;
}
echo("</table>");
?>
by the way...ANY comments to the lack of codeing is welcomed. I am learning and trying to eliminate all security holes at the same time (or as many as possible)
Lowell