Jump to content

Recommended Posts

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>";
?>

Link to comment
https://forums.phpfreaks.com/topic/46454-need-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.