ccutla Posted May 31, 2006 Share Posted May 31, 2006 I am having trouble with the paging of my search results, the first page of results shows up fine, and it shows the proper number of pages, but if I click on page 2 or more, it says that I have 0 pages of results. This is the script I have that runs the results of my search.PHP:<center><table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"><tr><td width="60"><b>DT_STRING</b></td><td width="100"><b>ACCOUNT</b></td><td width="30"><b>ACCOUNT_TYPE</b></td><td width="150"><b>CLIENT_ID</b></td><td width="150"><b>USER_ID</b></td></tr><tr><td><?php mysql_connect("mysql","root","rootroot");mysql_select_db("AUDITMED");$num = $_GET['num'];if(empty($num)){ $num = 1;}; $limit = 100;$start = ($num-1)*$limit; if ($start == 0){ $start = 1;} $metode = $_REQUEST['metode'];$search = $_REQUEST['search'];$metode2 = $_REQUEST['metode2'];$search2 = $_REQUEST['search2'];$metode3 = $_REQUEST['metode3'];$search3 = $_REQUEST['search3'];$query = "SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' AND $metode3 LIKE '%$search3%' ORDER by CLIENT_ID LIMIT $start, $limit"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ $variable1=$row["DT_STRING"]; $variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"]; $variable5=$row["USER_ID"]; //table layout for results echo ("<tr>"); echo ("<td>$variable1</td>"); echo ("<td>$variable2</td>"); echo ("<td>$variable3</td>"); echo ("<td>$variable4</td>"); echo ("<td>$variable5</td>"); echo ("</tr>");}; $totalpages = mysql_num_rows(mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' AND $metode3 LIKE '%$search3%'")); $totalpages = $totalpages / $limit; if ($totalpages == round($totalpages,0)) { $totalpages = round($totalpages,0) ; }else { $totalpages = round($totalpages,0) + 1; }$c = 0;echo "<br>";while($c<$totalpages){ $page = ++$c; if($_GET['num']==$page){ echo "[$page] "; }else{//else echo "<a href=?num=$page>[$page] </a>"; } } echo "<br>".$totalpages." Pages in total.";?> </table></center>What in the world am I missing? Link to comment https://forums.phpfreaks.com/topic/10876-paging-problem-with-limited-search-results/ Share on other sites More sharing options...
nogray Posted May 31, 2006 Share Posted May 31, 2006 Are you including these variables in your URL qurey?"<a href=?num=$page&...........>$metode = $_REQUEST['metode'];$search = $_REQUEST['search'];$metode2 = $_REQUEST['metode2'];$search2 = $_REQUEST['search2'];$metode3 = $_REQUEST['metode3'];$search3 = $_REQUEST['search3'];Otherwise the sql query won't find any data. Link to comment https://forums.phpfreaks.com/topic/10876-paging-problem-with-limited-search-results/#findComment-40628 Share on other sites More sharing options...
ccutla Posted May 31, 2006 Author Share Posted May 31, 2006 I have not done that, but I am kind of new to this so I can't seem to get it to work properly when I add the variables into the url string this is the way I'm trying to do it, but it definitely isn't working right.while($c<$totalpages){ $page = ++$c; if($_GET['num']==$page){ echo "[$page] "; }else{//else echo "<a href=?num=$page&[$metode = $_REQUEST['metode'];$search = $_REQUEST['search'];$metode2 = $_REQUEST['metode2'];$search2 = $_REQUEST['search2'];$metode3 = $_REQUEST['metode3'];$search3 = $_REQUEST['search3'];>[$page] </a>"; } } echo "<br>".$totalpages." Pages in total."; Link to comment https://forums.phpfreaks.com/topic/10876-paging-problem-with-limited-search-results/#findComment-40647 Share on other sites More sharing options...
nogray Posted May 31, 2006 Share Posted May 31, 2006 Sorry, I was just point to the variables. Here is how you should do it[code]echo "<a href=?num=$page&metode=$metode&search=$search&metode2=$metode2&search2=$search2&metode3=$metode3&search3=$search3>[$page] </a>";[/code] Link to comment https://forums.phpfreaks.com/topic/10876-paging-problem-with-limited-search-results/#findComment-40655 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.