Hello, i want to change te result of showing in the browser,
now it shows this when i click 2 3 4 or next.
Search+source+code&page=36
Search+source+code&page=72
Search+source+code&page=108
and i want to change it to this,
Search+source+code&page=2
Search+source+code&page=3
Search+source+code&page=4
If i change $per_page = 36; to $per_page = 1; than works everything fine but than i dont have 36 videos but 1. and i want to show 36 videos, here below is the complete script.
<?php
$button = $_GET ["submit"];
$search = $_GET ["search"];
if(strlen($search)<=1)
echo "Search term too short";
else{
echo "You searched for <b>$search</b> <hr size='1'></br>";
mysql_connect("mysql_host_name","mysql_username","mysql_password");
mysql_select_db("database_name");
$search_exploded = explode (" ", $search);
foreach($search_exploded as $search_each)
{
$x++;
if($x==1)
$construct .="title LIKE '%$search_each%'";
else
$construct .="AND title LIKE '%$search_each%'";
}
$constructs ="SELECT * FROM database_table_name WHERE $construct";
$run = mysql_query($constructs);
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "Sorry, there are no matching result for <b>$search</b>.</br></br>1.
Try more general words. for example: If you want to search 'how to create a website'
then use general keyword like 'create' 'website'</br>2. Try different words with similar
meaning</br>3. Please check your spelling";
else
{
echo "$foundnum results found !<p>";
$per_page = 36;
$page = $_GET["page"];
$max_pages = ceil($foundnum / $per_page);
if(!$page)
$page=0;
$getquery = mysql_query("SELECT * FROM database_table_name WHERE $construct LIMIT $page, $per_page");
while($runrows = mysql_fetch_assoc($getquery))
{
$title = $runrows ["title"];
$desc = $runrows ["description"];
$url = $runrows ["url"];
echo "
<a href='$url'><b>$title</b></a><br>
$desc<br>
<a href='$url'>$url</a><p>
";
}
//Pagination pages
echo "<center>";
$prev = $page - $per_page;
$next = $page + $per_page;
$adjacents = 3;
$last = $max_pages - 1;
if($max_pages > 1)
{
//previous button
if (!($page<=0))
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$prev'>Prev</a> ";
//pages
if ($max_pages < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
$i = 0;
for ($counter = 1; $counter <= $max_pages; $counter++)
{
if ($i == $page){
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$i'><b>$counter</b></a> ";
}
else {
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$i'>$counter</a> ";
}
$i = $i + $per_page;
}
}
elseif($max_pages > 5 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if(($page/$per_page) < 1 + ($adjacents * 2))
{
$i = 0;
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($i == $page){
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$i'><b>$counter</b></a> ";
}
else {
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$i'>$counter</a> ";
}
$i = $i + $per_page;
}
}
//in middle; hide some front and some back
elseif($max_pages - ($adjacents * 2) > ($page / $per_page) && ($page / $per_page) > ($adjacents * 2))
{
echo " <a href='search.php?search=$search&submit=Search+source+code&page=0'>1</a> ";
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$per_page'>2</a> .... ";
$i = $page;
for ($counter = ($page/$per_page)+1; $counter < ($page / $per_page) + $adjacents + 2; $counter++)
{
if ($i == $page){
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$i'><b>$counter</b></a> ";
}
else {
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$i'>$counter</a> ";
}
$i = $i + $per_page;
}
}
//close to end; only hide early pages
else
{
echo " <a href='search.php?search=$search&submit=Search+source+code&page=0'>1</a> ";
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$per_page'>2</a> .... ";
$i = $page;
for ($counter = ($page / $per_page) + 1; $counter <= $max_pages; $counter++)
{
if ($i == $page){
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$i'><b>$counter</b></a> ";
}
else {
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$i'>$counter</a> ";
}
$i = $i + $per_page;
}
}
}
//next button
if (!($page >=$foundnum-$per_page))
echo " <a href='search.php?search=$search&submit=Search+source+code&page=$next'>Next</a> ";
}
echo "</center>";
}
}
?>
Thank in advance