how to alphabitical...
Moderator: General Moderators
how to alphabitical...
Can someone help me on making a code that list users alphabitical(or however you spell it)?
-
Wldrumstcs
- Forum Commoner
- Posts: 98
- Joined: Wed Nov 26, 2003 8:41 pm
Should be something like
It will go in alphabetical order by last name. It will take into consideration the first name as well if the last names are the same. You can change 'username' to whatever the column is called in your DB.
Code: Select all
<?
mysql_connect("localhost","$username","$password") or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("$database") or die ("Unable to select requested database.");
$query=mysql_query("SELECT * FROM TABLENAME ORDER BY SUBSTRING_INDEX(username, ' ', -1),SUBSTRING_INDEX(username, ' ',1)");
while ($row = mysql_fetch_array($query)) {
$username=$rowї"username"];
echo "
<tr>
<td>$username</td>
</tr>
";
$row_count++;
}
?>mysql_connect("localhost","username","password)
or die(mysql_error());
mysql_select_db("database")
or die(mysql_error());
if you have something like that and all of your smurf is correct and you're still getting an error, it's likely that you don't have permissions set up correctly for the database.
or die(mysql_error());
mysql_select_db("database")
or die(mysql_error());
if you have something like that and all of your smurf is correct and you're still getting an error, it's likely that you don't have permissions set up correctly for the database.