Jump to content

Recommended Posts

I want to know how can I sort my members in a certain table from a-z, I have it sorted as z-a, i want to switch it up but have no clue on doing so.

Heres my displaying page:
[code]<?php
//PHP Adminpanel v1.0 //
include('config.php');

$connection = mysql_connect( "$host","$user","$pass" ) or die(mysql_error());

$rs = mysql_select_db( "$db" );

$sql=" select * from roster order by alias $sort ";

$rs = mysql_query($sql) or die(mysql_error());

echo '<table width="100%">
<tr>
<td bgcolor="1E1A13"><font face="verdana" size=2 color="FFFFFF"><b><center>Alias</b></td>
<td bgcolor="1E1A13"><font face="verdana" size=2 color="FFFFFF"><b><center>ClanRank:</b></td>
<td bgcolor="1E1A13"><font face="verdana" size=2 color="FFFFFF"><b><center>Division:</b></td>
<td bgcolor="1E1A13"><font face="verdana" size=2 color="FFFFFF"><b><center>Status:</b></td>
</tr>';
while ( $row = mysql_fetch_array( $rs) )
{
echo '
<tr>
<td bgcolor="99958E"><font face="verdana" size=1 color="FFFFFF">'.$row["alias"].'</td>
<td bgcolor="99958E"><font face="verdana" size=1 color="FFFFFF">'.$row["clanrank"].'</td>
<td bgcolor="99958E"><font face="verdana" size=1 color="FFFFFF">'.$row["division"].'</td>
<td bgcolor="99958E"><font face="verdana" size=1 color="FFFFFF">'.$row["status"].'</td>
</tr>
';
}
?>
[/code]

and the config:

[code]
<?php
//PHP Work//

// Set mysql server info here//

$host ="localhost"; //This is the mysql host//
$user ="user"; //This is the Mysql Username//
$pass ="password"; //This is the Mysql Password//
$db ="db"; //This is the Name of the Database you have the information stored in//
$sort ="desc"; //to sort the oldest to news shows enter asc to sort from newest to oldest enter desc //

?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/4305-sort-help/
Share on other sites

[!--quoteo(post=352421:date=Mar 7 2006, 02:52 AM:name=HaZaRd420)--][div class=\'quotetop\']QUOTE(HaZaRd420 @ Mar 7 2006, 02:52 AM) [snapback]352421[/snapback][/div][div class=\'quotemain\'][!--quotec--]
$sql=" select * from roster order by alias $sort ";

$sort ="desc"; //to sort the oldest to news shows enter asc to sort from newest to oldest enter desc //

[/quote]

You may want to try switching desc to asc. Descending typically means from Z-A, and Ascending typically means from A-Z. I'd give that a shot, though I could be way off here.
Link to comment
https://forums.phpfreaks.com/topic/4305-sort-help/#findComment-14974
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.