Hi im almost finished my website and it will be up and running hopefully but im struggling on getting the pagination to work on my search engine. It shows the first page of searches and does cut the page into 4 (or how ever many) searchs and when I click to the next page it just simply says the search bar error someone please help im desperate last part of my website to do?
Heres the code:
include("connect.php");
//max displayed per page
$per_page = 4;
//get start variable
$start = $_GET['start'];
//count records
$record_count = mysql_num_rows(mysql_query("SELECT * FROM search"));
//count max pages
$max_pages = $record_count / $per_page; //may come out as decimal
if (!$start)
$start = 0;
//get data
$button = $_GET['submit'];
$search = $_GET['search'];
if (!$button){
echo "<span class='class2 style39'>You didn't submit a keyword.</span>";
}else{
if (strlen($search)<=2){
echo "Search term too short.";
}else{
echo "You searched for <b>$search</b><hr size='1'>";
//connect to our datebase
include("connect.php");
//explode our search term
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each){
//construct query
$x++;
if ($x == 1){
$construct .= "keywords LIKE '%$search_each%'";
}else{
$construct .= "OR keywords LIKE '%$search_each%'";
}
}
$construct = "SELECT * FROM search WHERE $construct LIMIT $start, $per_page";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum == 0){
echo "No results found.";
}else{
echo "$foundnum results found!";
while ($runrows = mysql_fetch_assoc($run)){
//get data
$title = $runrows['title'];
$desc = $runrows['description'];
$url = $runrows['url'];
$picture = $runrows['picture'];
echo "<br/><br/><table width='600' align='center'>
<tr>
<td width='74' rowspan='3' align='left' valign='middle'><a href='$url'><img src='$picture' height='100' width='100' border='0'></a></td>
<td align='center' valign='middle'><b>$title</b></td>
</tr>
<tr>
<td align='center' valign='middle'>$desc</td>
</tr>
<tr>
<td align='center' valign='middle'><a href='$url'>$url</a></td>
</tr>
</table><p></p>";
}
//setup prev and next variables
$prev = $start - $per_page;
$next = $start + $per_page;
//show prev button
if (!($start<=0))
echo "<a href='videos.php?start=$prev'>Prev</a> ";
//show page numbers
//set variable for first page
$i=1;
for ($x=0;$x<$record_count;$x=$x+$per_page)
{
if ($start!=$x)
echo " <href='videos.php?start=$x'>$i</a> ";
else
echo " <a href='videos.php?start=$x'><b>$i</b> ";
$i++;
}
//show next button
if (!($start>=$record_count-$per_page))
echo " <a href='videos.php?start=$next'>Next</a>";
}
}
}