Hi, this is my first post so please ignore any newbie-like tendencies. I'm trying to use pagination to display search results. I know this topic has been dealt with alot but I have a specific problem that I can't seem to solve. My search query to access a mysql database is:
$query = "select * from media where title like '$title%' and id like '$random_idvideo%'
and medium like '$medium%' and year like '$year%' and course like '$course%' and subject like '$subject%' ORDER BY year DESC LIMIT $start, $display_number";
I use the following code for pagination:
if ($num_pages > 1) {
echo "<hr width=\"50%\" align=\"left\" />";
$current_page = ($start/$display_number) + 1;
if ($current_page !=1) {
echo '<a href="results.php?s=' . ($start - $display_number) . '&np=' . $num_pages . '&title=$title%&id=$random_idvideo%&medium=$medium%&year=$year%&course=$course%&subject=$subject%' .'">Previous</a> ';
}
for ($i = 1; $i <= $num_pages; $i++) {
if ($i != $current_page) {
echo '<a href="results.php?s=' . (($display_number * ($i - 1))) .'&np=' . $num_pages . '&title=$title%&id=$random_idvideo%&medium=$medium%&year=$year%&course=$course%&subject=$subject%' .'">' . $i . '</a> ';
} else {
echo $i . ' ';
}
}
if ($current_page != $num_pages) {
echo '<a href="results.php?s=' . ($start + $display_number) . '&np=' . $num_pages . '&title=$title%&id=$random_idvideo%&medium=$medium%&year=$year%&course=$course%&subject=$subject%' .'">Next</a> ';
}
}
mysql_free_result($query_result);
mysql_close();
This displays the first page of results nicely and has the links on the bottom displayed but when I click on a link the variables aren't passing to the next page. I know that you have to include the variables in the link somehow but I'm not sure how to do this correctly. Any help would be appreciated.
Thank You.