smileeman2002 Posted December 22, 2006 Share Posted December 22, 2006 Hi I am new to PHP ..CFMX convert.1. I have a simple GB and I want to display the data on multiple page. Like 10-20 per page. This is what I have done so far and it is okay but I have 293 entries so I have one long ugly page.This is how it looks: http://jupub.com/users2.php2. Also how can I put a space between each group of entries?<?php// Connects to your Databasemysql_connect("localhost", "user", "mypassword") or die(mysql_error());mysql_select_db("my_database") or die(mysql_error());$data = mysql_query("SELECT * FROM users")or die(mysql_error());Print "<table border=0 cellpadding=0>";while($info = mysql_fetch_array( $data )){Print "<tr>";Print "<th>Name:</th> <td>".$info['firstname'] . "</tr> ";Print "<th>Lastname:</th> <td>".$info['lastname'] . "</tr>";Print "<th>Location:</th> <td>".$info['location'] . "</tr> ";Print "<th>Comments:</th> <td>".$info['comments'] . " </tr>";}Print "</table>";?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>Untitled Document</title></head><body></body></html>thx Link to comment https://forums.phpfreaks.com/topic/31593-display-data-on-multiple-pages/ Share on other sites More sharing options...
utexas_pjm Posted December 22, 2006 Share Posted December 22, 2006 For pagination change your SQL to something like this:[code]<?php...$limit = 10;$page = 0;$data = mysql_query("SELECT * FROM users LIMIT " . $limit . " OFFSET " . ($page * $limit))...?>[/code]Each subsequent page increment the $page variable by 1. Link to comment https://forums.phpfreaks.com/topic/31593-display-data-on-multiple-pages/#findComment-146445 Share on other sites More sharing options...
.josh Posted December 22, 2006 Share Posted December 22, 2006 http://www.phpfreaks.com/tutorials/147/0.php Link to comment https://forums.phpfreaks.com/topic/31593-display-data-on-multiple-pages/#findComment-146458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.