0

Hello everyone.

I currently have a while loop that pulls all members to a page if the username begins with the selected letter. We have a lot of members now and the "usernames beginning with "a" are quite alot. So i need to be able to have a way to LIMIT to about 20 usernames then add a "new page" at the bottom. e.g i want like this at the bottom:

Page: 1 - 2 - 3 - 4 - 5 - 6, etc

And these are linked to the same page so the php code can list the next 20 members...

Here is my code at the minute and thank you very much in advance:

<?php
$letter = $_GET['sort'];
if(!isset($letter)) {
$letter = "a";
}
$lettercombo = "$letter%";
$select = mysql_query("SELECT * FROM users WHERE username LIKE '$lettercombo' ORDER by username");
while($fetch = mysql_fetch_array($select)) {
?>
  
  <tr>
   <td><a style="color:#5b9600; font-weight:bold; text-shadow:0px 1px 0px #fff;" href="viewuser.php?user=<? echo $fetch['username']; ?>"><? echo $fetch['username']; ?></a></td>
   <td><? echo $fetch['gamertag']; ?></td>
   <td><? echo $fetch['joined']; ?></td>
  </tr>
 
<? } ?>

Edited by BlueCharge: n/a

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

why dont you retrieve the contents of the while loop into an array and check if its greater than the limit 20.

Edited by anony: n/a

0

use queries like this
$res="mysql_query("SELECT * FROM users WHERE username LIKE '$lettercombo' ORDER by username");
$num=mysql_num_rows($res);
$limit=0;
$select = mysql_query("SELECT * FROM users WHERE username LIKE '$lettercombo' ORDER by username limit $limit-20");
while($fetch = mysql_fetch_array($select)) {

?>

<tr>
<td><a style="color:#5b9600; font-weight:bold; text-shadow:0px 1px 0px fff;" href="viewuser.php?user=<? echo $fetch; ?>"><? echo $fetch; ?></a></td>
<td><? echo $fetch; ?></td>

<td><? echo $fetch; ?></td>

</tr>


<? $limit+=20} ?>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.