Dewster Posted April 10, 2007 Share Posted April 10, 2007 Can anyone help me out with this, I'm a newbie and been having problems with this. You select the query from the main page and sends it to this code which gets the result and displays it page by page, the problem is that I can't get the rest of the records to display on the next page; everything else works fine. Thanks <?php $selectquery = "SELECT * FROM listings WHERE city = '$city' "; //echo "$selectquery"; $result = mysql_query($selectquery) or die ("Query failed"); while ($row = mysql_fetch_array($result)) if(!isset($start)) { // This variable is set to zero for the first page $start = 0; } $eu = ($start - 0); $limit = 5; // No of records to be shown per page. $this1 = $eu + $limit; $back = $eu - $limit; $next = $eu + $limit; // Finds out the number of records in our table. Use this to break the pages// $query2="SELECT * FROM listings WHERE city = '$city'"; $result2=mysql_query($query2); echo mysql_error(); $nume=mysql_num_rows($result2); //echo $nume; // The variable nume above will store the total number of records in the table// // Now let us start executing the query with variables $eu and $limit set at the top of the page// $query="SELECT * FROM listings WHERE city = '$city' limit $eu, $limit "; $result=mysql_query($query); echo mysql_error(); //echo $result; // Displays the returned records in side the rows of the table// while($row = mysql_fetch_array($result)) { if($bgcolor=='#ffffff'){$bgcolor='#ffffff';} else{$bgcolor='#ffffff';} echo "<tr >"; echo "<td align=center bgcolor=$bgcolor id='title'> <font face='Verdana' size='-10'>$row[fname] $row[lname]</font></td>"; echo "<td align=center bgcolor=$bgcolor id='title'> <font face='Verdana' size='-10'>$row[compn]</font></td>"; echo "<td align=center bgcolor=$bgcolor id='title'> <font face='Verdana' size='-10'>$row[addone]</font></td>"; echo "<td align=center bgcolor=$bgcolor id='title'> <font face='Verdana' size='-10'>$row[city],$row[prov], $row[postcode]</font></td></font></td>"; echo "<td align=center bgcolor=$bgcolor id='title'> <font face='Verdana' size='-10'>$row[phonen]</font></td>"; echo "<td align=center bgcolor=$bgcolor id='title'> <font face='Verdana' size='-10'>$row[accpt]</font></td>"; echo "</tr>"; } echo "</table>"; // End of displaying the table with records // // If we are not in the last page then Next link will be displayed. // if($this1 < $nume) { print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";} echo "</td></tr></table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/46454-need-help/ Share on other sites More sharing options...
cmgmyr Posted April 10, 2007 Share Posted April 10, 2007 you have to offset and limit your query. Also what does this have to do with OOP? Quote Link to comment https://forums.phpfreaks.com/topic/46454-need-help/#findComment-225978 Share on other sites More sharing options...
Dewster Posted April 10, 2007 Author Share Posted April 10, 2007 Sorry my mistake Quote Link to comment https://forums.phpfreaks.com/topic/46454-need-help/#findComment-225982 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.