Need direction on sorting MySQL output
Posted: Thu Mar 04, 2010 2:52 pm
Hi All,
I'm new here an am looking for some direction. I have been playing around with MySQL and php and want to know what would be the easiest way to accomplish a sorting mechanism on this page: http://www.garrettajohnson.com/cell/test.php
Here's the page's code, I would really like to read a tutorial and have been searching for one for a while, but have not found anything that is useful, maybe some of you have an idea.
I'm new here an am looking for some direction. I have been playing around with MySQL and php and want to know what would be the easiest way to accomplish a sorting mechanism on this page: http://www.garrettajohnson.com/cell/test.php
Here's the page's code, I would really like to read a tutorial and have been searching for one for a while, but have not found anything that is useful, maybe some of you have an idea.
Code: Select all
<html>
<body>
<?php
$username="*******";
$password="*******";
$database="*******";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM verizon";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
?>
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif">Billing Account Number</font></th>
<th><font face="Arial, Helvetica, sans-serif">Invoice Date</font></th>
<th><font face="Arial, Helvetica, sans-serif">Mobile Number</font></th>
<th><font face="Arial, Helvetica, sans-serif">First Name</font></th>
<th><font face="Arial, Helvetica, sans-serif">Last Name</font></th>
<th><font face="Arial, Helvetica, sans-serif">Total Charges</font></th>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"Billing Account Number");
$f2=mysql_result($result,$i,"Invoice Date");
$f3=mysql_result($result,$i,"Mobile Number");
$f4=mysql_result($result,$i,"First Name");
$f5=mysql_result($result,$i,"Last Name");
$f6=mysql_result($result,$i,"Total Charges");
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f6; ?></font></td>
</tr>
<?php
$i++;
}
?>
</body>
</html>