sorting numbers in a text colomn
Posted: Fri Oct 24, 2003 11:28 am
I am trying to correctly sort numbers in a text colum (1,2,3,4....,10,11) and it currently sorts them (1,10,100,101,2,20...) How do I do this?? My code is below. Thanks:
$strSQL = "SELECT item, min(amount), max(amount) FROM bidlog WHERE code='K' and auction='$short_auction_name' GROUP BY item ORDER BY item";
$result = pg_exec($con, $strSQL);
if(!$result)
{
print("<SCRIPT>alert('An unknown error occurred. The bidder information could not be retrieved, please try again. If it does not work contact AMS.')</SCRIPT>\n");
return "false";
}
echo '<table align=center cellpadding=5><tr><th bgcolor="#C0C0C0">Item</th><th bgcolor="#C0C0C0">Start Bid</th><th bgcolor="#C0C0C0">End Bid</th><th bgcolor="#C0C0C0">Value Added</th></tr> ';
for ($y=0;$y<pg_numrows($result);$y++){
$data = pg_fetch_array($result,$y);
$value_added = $data[2]-$data[1];
echo "<tr bgColor=#dddddd><th><font color=red>$data[0]</font></th><th>$$data[1]</th><th>$$data[2]</th><th><I>$$value_added</I></th></tr>";
}
echo '</table>';
$strSQL = "SELECT item, min(amount), max(amount) FROM bidlog WHERE code='K' and auction='$short_auction_name' GROUP BY item ORDER BY item";
$result = pg_exec($con, $strSQL);
if(!$result)
{
print("<SCRIPT>alert('An unknown error occurred. The bidder information could not be retrieved, please try again. If it does not work contact AMS.')</SCRIPT>\n");
return "false";
}
echo '<table align=center cellpadding=5><tr><th bgcolor="#C0C0C0">Item</th><th bgcolor="#C0C0C0">Start Bid</th><th bgcolor="#C0C0C0">End Bid</th><th bgcolor="#C0C0C0">Value Added</th></tr> ';
for ($y=0;$y<pg_numrows($result);$y++){
$data = pg_fetch_array($result,$y);
$value_added = $data[2]-$data[1];
echo "<tr bgColor=#dddddd><th><font color=red>$data[0]</font></th><th>$$data[1]</th><th>$$data[2]</th><th><I>$$value_added</I></th></tr>";
}
echo '</table>';