I want to query limited result only on one page.
For example, the query will show 30 users from database on page 1, and then continue with another 30 on page 2 etc. For example Facebook messages when you go to conversation history and you have to click "show more" to load more previous messages.
EDIT:
<?php
$dbhost = '';
$dbuser = '';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$sql = "SELECT * FROM members ORDER BY username";
mysql_select_db('');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
if($row['picture'] == ""){
echo "<img src='profile_pictures/public_icon.png' width='46' height='50'><br>";}else {
echo " <img width='50' height='50' src='profile_pictures/".$row['picture']."' alt='Profile Pic'><br>";
}
echo "<b>Email:</b> {$row['email']} <br> ";
echo "<b>Username: </b>{$row['username']} </p> ";
echo "<hr class='hr' />";
}
?>
This shows ALL user's information (email, profile picture and username) separated with hr.
The problem is that it displays ALL on one page. It would be big problem if there would be registered for example 1000 users.
You will need two pages : the first one gets the data from database, the second shows the data paged. Next example works with an array, copy-paste the code in files with the given names, open your browser, and type "localhost/show5_first.php" in the address bar :
show5_first.php
show5_rest.php