I have a problem. I want to display 1000 records in page by page with 25 records in each page. and page number at the bottom as page link. Now I am displaying all records in one page with following codes.
$qtable = "users"; $qfields = "username, purchases"; $qcondition = "where uid='$current_uid' and purchases!= 0"; $qresult = mysql_query("select $qfields from $qtable$qcondition");
$i=mysql_num_rows($qresult);
list( $username)=mysql_fetch_row($qresult);
$username=stripslashes($username);
if($i < 1 ) { die("<img src=no-entry.jpg align='center'> <font size=2 color=red><b>Sorry, you have no access to this section.<br> Please contact the system administrator.<b></font>"); }//done
Ive not altered your code just go through this snippet that i have used may be this will defenitely help you a lot
PHP Code:
<?php
//Create a connection to yourserver. //Print error message to user if connection to server has failed. $connection = mysql_connect("localhost", "root","pass")or die ("Unable to connect to SERVER");
//database name $db="db_name"; $database = @mysql_select_db($db,$connection)or die ("could not select database "); // database connection stuff here $rows_per_page = 10; $sql = "SELECT * FROM tbl"; $result = mysql_query($sql, $connection); //calculating the total number of rows present in the table; $total_records = mysql_num_rows($result); //finding out how many pages that will be printed. $pages = ceil($total_records / $rows_per_page); //echo "$total_records"; // Free result mysql_free_result($result);
/**NEXT SECTION**/ if (!isset($screen)) $screen = 0;