For example, there are 3 pages with 5 usernames on each, the top username is missing on every page so it is only showing 12 when it should be showing 15.
I was wondering if anyone could tell me what could cause this in the following script:
NOTE: The where section is commented out as I am not using it.
Expand|Select|Wrap|Line Numbers
- <?
- include('header.php');
- include('navigation.php');
- include('content.php');
- function pagenav() {
- global $limit,$offset,$numpage,$where;
- if ($where) {
- $safewhere=urlencode($where);
- }
- if ($offset>=$limit) {
- $newoff=$offset-$limit;
- echo "<a href=\"$PHP_SELF?offset=$newoff&where=$safewhere\">
- <-- PREV</a>
- ";
- } else {
- echo "<-- PREV";
- }
- echo " ";
- for ($i=1;$i<=$numpage;$i++) {
- if ((($i-1)*$limit)==$offset) {
- print "$i ";
- } else {
- $newoff=($i-1)*$limit;
- echo "<a class=\"pageno\" href=\"$PHP_SELF?offset=$newoff&where=$safewhere\">
- $i</a> ";
- }
- }
- echo " ";
- if ($offset!=$limit*($numpage-1)) {
- $newoff=$offset+$limit;
- echo "<a href=\"$PHP_SELF?offset=$newoff&where=$safewhere\">
- NEXT--></a>
- ";
- }else{
- echo "NEXT-->";
- }
- } // END FUNCTION
- // set this to the number of results you wish on each page
- $limit=3;
- // if no offset has been passed, offset should be 0
- if (!$offset) {
- $offset=0;
- }
- /*
- if (!$where) // where was not passed {
- if (empty($one) || empty($two)) {
- // some error handling as $one
- //and/or $two not passed to initial page
- }
- $where="$one|$two";
- // NOTE: if a pipe (|) may be in the value
- //of $one or $two, use a different delimiter
- $data=explode('|',$where);
- $query_where="where one='$data[0]' AND two='$data[1]'";
- */
- $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
- ?>
- <form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
- <input type="text" name="reqprof" value="Enter Username" />
- <input type="submit" name="submit" value="Get Link" />
- </form>
- <?
- if($_POST['reqprof']){
- $reqname = $_POST['reqprof'];
- $userlink = "profile.php?user=$reqname";
- echo "<a href=\"$userlink\">View Profile</a>";
- }
- ?>
- <table class="browse">
- <?
- $result=mysql_query("select * from users limit $offset,$limit");
- $row=mysql_fetch_assoc($result);
- while($row=mysql_fetch_array($result))
- {
- echo "<tr><td class=\"browse\">";
- echo "<div class=\"profiletext\">";
- echo $row['username'];
- echo "</div>";
- echo "<br />";
- ?>
- <img src="uploads/photo/<? echo $row['photo']; ?>" alt="<? echo $row['username'] ?>'s Display Picture" />
- <?
- echo "</td>";
- ?>
- <td class="browse"><a href="profile.php?user=<? echo $row['username'] ?>">Profile</a></td></tr>
- <?
- }
- ?>
- </table>
- <br />
- <?
- if ($numpage>1) {
- pagenav();
- print "<p>";
- }
- include('endcontent.php');
- include('advert.php');
- include('footer.php');
- ?>