I've got this code to work spitting out the records from left to right but when i limit the amount of records to a specific number all of the records still show up on the same page. I can click to go to the next page but it looks like the page before it with the same records appearing. I have another script that puts the records in rows rather than columns. the rest of the code for pagination is the same and that script works fine. Please take a look. I'cve looked at quite a few pagination post and didn't see anything that quite fit my problem. Both scripts are posted below
Thanks
===Columns===Doesn't Work!
<?php
require "config.php";
if(empty($uid)) {
header("Location: ./index.php");
} else {
include "header.php";
dbcnx();
$oq_limit = "30";
$userz = mysql_query("SELECT * FROM $db[users] WHERE app = '0'");
$num_userz = mysql_num_rows($userz);
//Page #'s
$n_pages = ceil($num_userz / $oq_limit);
if($n_pages>1) {
$top_message = " <b>(Pages:</b> ";
for($i=1;$i<=$n_pages;$i++)
{
if($i==1) {
$top_message .= "<a href=\"./list.php\">$i</a> ";
} else {
$top_message .= "<a href=\"./list.php?page=".($oq_limit * ($i-1))."\">$i</a> ";
}
}
$pages = $top_message."<b> )</b>";
}
if(!isset($page)){
$query = mysql_query("SELECT * FROM $db[users] WHERE app='0' ORDER BY screename LIMIT 0,$oq_limit");
} else {
$query = mysql_query("SELECT * FROM $db[users] WHERE app='0' ORDER BY screename LIMIT $page,$oq_limit");
}
//$query = mysql_query("SELECT * FROM $db[users] ORDER BY $screename $sort");
$query_t = mysql_query("SELECT * FROM $db[users] WHERE app='0' ORDER BY screename");
//$query_t = mysql_query("SELECT * FROM $db[users] LIMIT 0, 30");
print "<b>Current Total: " . mysql_num_rows($query_t)."</b><br>$pages";
//set number of columns
$columns = 5;
$count = 5;
$num_rows = mysql_num_rows($userz);
echo "<table cellspacing=\"10\" cellpadding=\"0\" bordercolor=\"#111111\">";
echo "<tr>";
for($i=0; $i < $num_rows; $i++)
{
$row = mysql_fetch_array ($userz);
if($i % $columns == 0 && $i != 0)
{
echo "</tr>";
echo "<tr>";
$count = 0;
}
echo "<td align =\"center\" vlign = \"top\"><a href=\" ./userinfo.php?id=". $row['id'] . "\"><img border=\"0\" src=\"photogallery/photos/". $row['image'] . "\" width=\"100\" height=\"135\"><br>";
echo "<small>" . $row['first'] ." ". $row['last'] . "</a><br>";
echo "Member Since ". $row['joindate'] ."</small> <br>";
echo "</td>";
$count++;
}
// This makes sure all the columns are filled
// Without this, when $num_rows % $columns does not equal 0
// There would be less columns in the last <tr> then $columns
if($columns != $count)
{
for($i = 0; $i < ($columns - $count); $i++)
{
echo"<td bgcolor=ffffff> </td>"; //Change this if you want to fill it with something else
}
}
echo "</tr>";
echo "</table>";
print "<b>Current Total: " . mysql_num_rows($query_t)."</b><br>$pages";
include "footer.php";
}
?>
===Rows===Works Fine!
<?php
require "config.php";
if(empty($uid)) {
header("Location: ./index.php");
} else {
include "header.php";
dbcnx();
$oq_limit = $cfg['mems'];
$userz = mysql_query("SELECT * FROM $db[users] WHERE app = '0'");
$num_userz = mysql_num_rows($userz);
//Page #'s
$n_pages = ceil($num_userz / $oq_limit);
if($n_pages>1) {
$top_message = " <b>(Pages:</b> ";
for($i=1;$i<=$n_pages;$i++)
{
if($i==1) {
$top_message .= "<a href=\"./list.php\">$i</a> ";
} else {
$top_message .= "<a href=\"./list.php?page=".($oq_limit * ($i-1))."\">$i</a> ";
}
}
$pages = $top_message."<b>)</b>";
}
if(!isset($page)){
$query = mysql_query("SELECT * FROM $db[users] WHERE app='0' ORDER BY screename LIMIT 0,$oq_limit");
} else {
$query = mysql_query("SELECT * FROM $db[users] WHERE app='0' ORDER BY screename LIMIT $page,$oq_limit");
}
$query_t = mysql_query("SELECT * FROM $db[users] WHERE app='0' ORDER BY screename");
print "<b>Current Total: " . mysql_num_rows($query_t)."</b><br>$pages";
print "<table width=\"99%\" border=\"1\" cellspacing=\"0\">\n<tr bgcolor=\"$bgcolor2\"><th>Picture</th><th>Name</th><th>Maiden Name</th><th>Email</th></tr>\n";
while($user=mysql_fetch_array($query)) {
print "<td valign=\"middle\" align=\"center\" width=\"75\"><a href=\"./userinfo.php?id=$user[id]\"><img border=\"0\" src=\"./photogallery/photos/$user[image]\" width=\"75\" height=\"101\">
</a></td><td>";
if(!empty($user[last])) { print "$user[last], "; }
print "$user[first]</td><td valign=\"middle\" width=\"150\"> ";
if(!empty($user[maidenname])) { print "$user[maidenname], "; }
print "$user[maidenname]</td><td valign=\"middle\" width=\"60\"> ";
if(!empty($user[email])) { print "<a href=\"mailto:$user[email]\">Email</a>"; }
print " </td></tr>";
}
print "</table>$pages";
include "footer.php";
}
?>