Jump to content


Photo

Sort Help!


  • Please log in to reply
2 replies to this topic

#1 HaZaRd420

HaZaRd420
  • Members
  • PipPipPip
  • Advanced Member
  • 37 posts

Posted 07 March 2006 - 07:52 AM

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:
<?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>
';
}
?>

and the config:

<?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 //

?>


#2 Fred708

Fred708
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 07 March 2006 - 08:01 AM

[!--quoteo(post=352421:date=Mar 7 2006, 02:52 AM:name=HaZaRd420)--][div class=\'quotetop\']QUOTE(HaZaRd420 @ Mar 7 2006, 02:52 AM) View Post[/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.

#3 HaZaRd420

HaZaRd420
  • Members
  • PipPipPip
  • Advanced Member
  • 37 posts

Posted 07 March 2006 - 08:03 AM

Hey Blurring, that worked out, Thanks alot. It was right in front of my eyes!!! Thanks alot man!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users