Jump to content

pagination & $_GET[];


Ltj_bukem

Recommended Posts

 

Hi, I've got a search script which queries the database and displays the results using pagination. The script works fine, however if

you select a new page (i.e page 2) every record in that table is shown, it's as if a new query has been asked. I'm guessing that it has something to do with $_GET[] or $_POST[];. I've tried to display the search on page 2 by placing the search into a new variable and then using echo but I get nothing.

 

Here's the script

 


<?php


          $pagenum = $_GET['pagenum'];

          $search= $_POST['search'];
       
mysql_connect("*****", "***", "*****") or die(mysql_error());

mysql_select_db("*****") or die(mysql_error());

if (!(isset($pagenum)))

{

$pagenum = 1;

}

$data = mysql_query("SELECT * FROM download WHERE dance LIKE '%$search%' OR name LIKE '%$search%'") or die(mysql_error());

$rows = mysql_num_rows($data);



echo "Searching for $search produced $rows results";  

echo "<br></br>";   

$page_rows = 20;

$last = ceil($rows/$page_rows);

$total_pages = ceil($rows/$page_rows);


if ($pagenum < 1)

{

$pagenum = 1;

}

elseif ($pagenum > $last)

{

$pagenum = $last;

}

$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;


$data_p = mysql_query("SELECT * FROM download WHERE dance LIKE '%$search%' OR name LIKE '%$search%'$max") or die(mysql_error());




while (list($id, $name, $temp, $dance) = mysql_fetch_array($data_p))    {

echo "<a href=\"download3.php?id=$id\">$name</a></br>";

  } 

           ?>

                              

   <br>

         <br>

            <?php

            if ($rows>10){
				            ?>

            <table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">

           <tr>

            <td><hr noshade color="#FFFFFF" align="left" width="100%" size="1"> </td>

          </tr>

          <tr>

            <td align="center">

            <?php

                              

              include('paging.php');

            ?>

           </td>

          </tr>

          </table><br>

           <?php } ?>

 

Any thoughts?

Link to comment
https://forums.phpfreaks.com/topic/79393-pagination-_get/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.