I used Dream weaver to bind the database and display the contents from the table. The problem is I CAN DISPLAY only 10 rows per page. I want to have a next Button which shows the other 10 rows in another page.
<?php
$maxRows_rs_contact = 10;
$pageNum_rs_contact = 0;
if (isset($HTTP_GET_VARS['pageNum_rs_contact']))
{
$pageNum_rs_contact = $HTTP_GET_VARS['pageNum_rs_contact'];
}
$startRow_rs_contact = $pageNum_rs_contact * $maxRows_rs_contact;
//mysql_select_db($database_dbconnect, $dbconnect);
$query_rs_contact = "SELECT * FROM contact";
$query_limit_rs_contact = sprintf("%s LIMIT %d, %d", $query_rs_contact, $startRow_rs_contact, $maxRows_rs_contact);
$rs_contact = mysql_query($query_limit_rs_contact, $connect) or die(mysql_error());
$row_rs_contact = mysql_fetch_assoc($rs_contact);
if (isset($HTTP_GET_VARS['totalRows_rs_contact'])) {
$totalRows_rs_contact = $HTTP_GET_VARS['totalRows_rs_contact'];
} else {
$all_rs_contact = mysql_query($query_rs_contact);
$totalRows_rs_contact = mysql_num_rows($all_rs_contact);
}
$totalPages_rs_contact = ceil($totalRows_rs_contact/$maxRows_rs_contact)-1;
?>
<table border="1">
<tr>
<td>Name</td>
<td>Phone</td>
<td>Email</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_rs_contact['Name']; ?></td>
<td><?php echo $row_rs_contact['Phone']; ?></td>
<td><?php echo $row_rs_contact['Email']; ?></td>
</tr>
<?php } while ($row_rs_contact = mysql_fetch_assoc($rs_contact)); ?>
</table>
Need Help Displaying the Contents from the table
Moderator: General Moderators
- launchcode
- Forum Contributor
- Posts: 401
- Joined: Tue May 11, 2004 7:32 pm
- Location: UK
- Contact:
So that's what Dreamweaver PHP code looks like!
Ick
Anyway, in looking at the code I see no reason at all why you cannot do what you want. You just need a link in your page that sets the pageNum_rs_contact.
Ick
Anyway, in looking at the code I see no reason at all why you cannot do what you want. You just need a link in your page that sets the pageNum_rs_contact.
Code: Select all
<?php
$nextpage = $pageNum_rs_contact + 1;
echo "<a href="script.php?pageNum_rs_contact=$nextpage">Next Page</a>";
?>- launchcode
- Forum Contributor
- Posts: 401
- Joined: Tue May 11, 2004 7:32 pm
- Location: UK
- Contact:
Post the error you get (if any).
It should be substituted for whatever your script is called (you never said in your original post).
Try changing this part at the start of your script:
Also echo out the value of $pageNum_rs_contact, or the SQL query itself so you can start debugging the thing.
It should be substituted for whatever your script is called (you never said in your original post).
Try changing this part at the start of your script:
Code: Select all
$pageNum_rs_contact = 0;
if (isset($HTTP_GET_VARS['pageNum_rs_contact']))
{
$pageNum_rs_contact = $HTTP_GET_VARS['pageNum_rs_contact'];
}
to
if (isset($_GET['pageNum_rs_contact']))
{
$pageNum_rs_contact = $_GET['pageNum_rs_contact'];
}
else
{
$pageNum_rs_contact = 0;
}