searls03 Posted January 28, 2014 Share Posted January 28, 2014 my php query: <?php $sql1 = mysql_query("SELECT * FROM attendance ORDER BY id ASC"); while($row1 = mysql_fetch_array($sql1)){ $current = $row1["id"]; $name = $row1["name"]; echo $current; echo "<br>"; } is not sorting properly. it is putting all 6 digit numbers before 5 digit numbers....here is what it is returning 100000 ... 311655311657311711311789311790311791311792311793311794311795693266939069451695479998599989999909999199992999939999599996999979999899999 does it have anything to do with the numbers not being consecutive? I can't have this.......I have another insert query that adds one to the last number output....which clearly it won't do because the new would be the same as the first number. can anyone help me with this? Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 28, 2014 Share Posted January 28, 2014 (edited) Nope, it is sorting in alphanumeric order. A '3' comes before '6'. This tells me that you have the 'id' field set as a varchar or some other non-numeric (i.e. text) type. Your ID field should be changed to an INT (integer) type so that it knows to sort in numeric order. What does the following query return SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'attendance' AND COLUMN_NAME = 'id' Edited January 28, 2014 by Psycho Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.