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>";

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

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

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

Use UNSIGNED

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.