0

i got the following entry in my dtabase..
field: poNo
001
002
003
004
005
006
007
008
009
0010
0011
0012
0013

if i issue in my php program this sql statement:

$query = "SELECT * FROM po ORDER BY poNo ASC";

the result is:
001
0010
0011
0012
0013
002
003
004
005
006
007
008
009

which is not my desired output.. i need it to be on sequence like this.
001
002
003
004
005
006
007
008
009
0010
0011
0012
0013

please help..

by the way, my php code is the following:

$query = "SELECT *
                        FROM po ORDER BY poNo ASC";
            $result = mysql_query($query);
             echo "<table border=1 style='border-collapse: collapse' width=95%>";
             echo "<tr class='tableheader'> 
                    <td>DATE</td> 
                    <td>P.O.#</td>                 
                     <td>SUPPLIER</td>
                     <td>AMOUNT</td>
                     <td>CODE</td>
                     <td></td>
                     <td></td>
                   </tr>";
                while ($records =  mysql_fetch_array($result)){
                   echo "<tr> 
                    <td>{$records['date']}</td> 
                    <td>{$records['poNo']}</td>                 
                     <td>{$records['supplier']}</td>
                     <td>{$records['tAmount']}</td>
                     <td>{$records['code']}</td>
                     <td><a href=purchaseOrder.php?page=23?&poNo={$records['poNo']}>[UPDATE]</td>
                     <td><a href=purchaseOrder.php?page=24?&poNo={$records['poNo']}>[DELETE]</td>
                   </tr>";
                }
                echo "</table>";
2
Contributors
4
Replies
22
Views
3 Years
Discussion Span
Last Post by lloydsbackyard
0

That is because you are storing the poNo as a string. Try this:

SELECT * FROM po ORDER BY CAST(poNo AS INTEGER) ASC
0

i tried pasting this in wampserver sql.. i gotthis error...#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTEGER) ASC LIMIT 0, 30' at line 1

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.