Forum Moderators: coopster
I'm using the following script:
<?
include('header.php');
include('navigation.php');
include('content.php');
function pagenav() {
global $limit,$offset,$numpage,$where;
if ($where) {
$safewhere=urlencode($where);
}
echo "
<table cellpadding=0 border=0 cellspacing=5 width=100>
<tr>
<td align=right>";
if ($offset>=$limit) {
$newoff=$offset-$limit;
echo "<a href=\"$PHP_SELF?offset=$newoff&where=$safewhere\">
<-- PREV</a>
</td>";
} else {
echo "<-- PREV";
}
echo "<td align=center> ";
for ($i=1;$i<=$numpage;$i++) {
if ((($i-1)*$limit)==$offset) {
print "$i ";
} else {
$newoff=($i-1)*$limit;
echo "<a href=\"$PHP_SELF?offset=$newoff&where=$safewhere\">
$i</a> ";
}
}
echo " </td>
<td align=left>";
if ($offset!=$limit*($numpage-1)) {
$newoff=$offset+$limit;
echo "<a href=\"$PHP_SELF?offset=$newoff&where=$safewhere\">
NEXT--></a>
</td>";
}else{
echo "NEXT--></td>";
}
echo "</tr>
</table>";
} // END FUNCTION
$limit=10;
if (!$offset) {
$offset=0;
}
$result=mysql_query("select count(*) from users");
list($numrec)=mysql_fetch_row($result);
#calc num pages
$numpage=intval($numrec/$limit);
if ($numrec%$limit) $numpage++; // add one page if remainder
$result=mysql_query("select * from users limit $offset,$limit");
if ($numpage>1) {
pagenav();
print "<p>";
}
if ($numpage>1) {
pagenav();
print "<p>";
}
include('endcontent.php');
include('advert.php');
include('footer.php');
?>
I had a few errors coming up which I got rid of and now it just displays my layout normally with nothing in the content area.
Thanks for any help.
then check your IF statements and you will get somewhere surely.
$result=mysql_query("select * from users limit $offset,$limit");
line you want something like:
$row=mysql_fetch_assoc($result);
while($row['field_name'])
{
echo $row['field_name']."<br>";
}
This will display the user names a line at a time, (field_name being the field name for the user name within the db).