Hello ,
I have developed a web page that includes a search engine that search in the database and find items that includes the keyword that the user typed and displays the results. The results(the image of every item) are displayed in 4 columns and 4 rows(totally 16 items) and if they are more that 16 it goes to the next page and if are more than 32 it goes to the next page.The user can navigate to the first ,second, third or as many pages as there are the results.
For example: search results page 1/2/3/4
item1 item2 item3 item4
item5 item6 item7 item8
item9 item10 item11 item12
item13 item14 item15 item16
if user select the search result for page 2
item17 item18 item19 item20
item21 item22 item23 item24
item25 item26 item27 item28
item29 item30 item31 item32
the same for the rest of the pages
I have manage to display the correct results in 4 columns and 4 rows but the problem i have and i need your help is regariding the navigation in the next or previous page.
Here is my existing code:
The code for the form that has the search
HTML Code:
<form name="form1" method="post" action="search_term.php" >
<input name="search" type="text" id="search">
<input type="submit" name="Submit" value="GO">
</form>
PHP Code:
<!-- display the results from the search -->
<table width="133" border="0" align="left" cellspacing="2">
<?
$sqlcolour = "Select * from Items where title like '%$title%' or description like '%$title%' order by Items.itemID limit 16";
$rsProducts =mysql_query($sqlcolour);
$p=0;
echo "<TR>";
while ($row = mysql_fetch_assoc($rsProducts)) {
$itemID=mysql_result($rsProducts,$p,"itemID");
$ref=mysql_result($rsProducts,$p,"ref");
$image=mysql_result($rsProducts,$p,"image");
$title=mysql_result($rsProducts,$p,"title");
$category_name=mysql_result($rsProducts,$p,"category_name");
$categoryID=mysql_result($rsProducts,$p,"categoryID");
$description=mysql_result($rsProducts,$p,"description");
$price=mysql_result($rsProducts,$p,"price");
$available=mysql_result($rsProducts,$p,"available");
$matchA=mysql_result($rsProducts,$p,"matchA");
$matchB=mysql_result($rsProducts,$p,"matchB");
$matchC=mysql_result($rsProducts,$p,"matchC");
$stone=mysql_result($rsProducts,$p,"stone");
$metal=mysql_result($rsProducts,$p,"metal");
if ($p > 0 && $p % 4 == 0) {
echo "</TR><TR>";
}
?>
<td width="47" height="53" align="center" class="bodytext">
<form action="item_details.php" method="get" target="frame1">
<input name='imageField' type='image' src="images/small_images/small_<? echo $image; ?>">
<input name="itemID" type="hidden" value="<? echo $itemID; ?>">
</form> </td>
<?
$p++;
}
?>
</tr>
</table>
<!--ends the search -->
I would realy appreciate your help in the problem.
Thanks,
Xenia