Domain Empire

[PHP]Users list

Spaceship Spaceship
Watch
Impact
1,418
A really simple php users list.

The code:

PHP:
<?php
$sql = "SELECT * FROM users ORDER BY user";
$res = mysql_query($sql);

if (mysql_num_rows($res)){
while ($list = mysql_fetch_array($res)) {

$letter = strtoupper(substr($list['user'],0,1));

if ($letter != $prev_row) {
echo "<br /><b><u>$letter</u></b><br />";
} 

echo "<a href='#'>{$list['user']}</a> <br />";

$prev_row = $letter;
}
?>

Will output this:

1zodlwz.jpg


Enjoy!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Instead of

PHP:
$letter = strtoupper(substr($list['user'],0,1));

You could also
PHP:
$letter = strtoupper($list['user']{0});
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back