MDanz Posted March 6, 2010 Share Posted March 6, 2010 how do i add numbering to mysql results? e.g. 1. result 2. result 3. result Link to comment https://forums.phpfreaks.com/topic/194313-how-to-number-mysql-results/ Share on other sites More sharing options...
vividona Posted March 6, 2010 Share Posted March 6, 2010 $i = 1; while($row = mysql_fetch_array($q){ echo $i++; } It will count when fetch your records; Link to comment https://forums.phpfreaks.com/topic/194313-how-to-number-mysql-results/#findComment-1022225 Share on other sites More sharing options...
MDanz Posted March 6, 2010 Author Share Posted March 6, 2010 what is $q... the query? Link to comment https://forums.phpfreaks.com/topic/194313-how-to-number-mysql-results/#findComment-1022228 Share on other sites More sharing options...
MDanz Posted March 6, 2010 Author Share Posted March 6, 2010 i get this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL Link to comment https://forums.phpfreaks.com/topic/194313-how-to-number-mysql-results/#findComment-1022229 Share on other sites More sharing options...
vividona Posted March 6, 2010 Share Posted March 6, 2010 i get this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL Sorry I forget something $i = 1; while($row = mysql_fetch_array($q)){ echo $i++; } Link to comment https://forums.phpfreaks.com/topic/194313-how-to-number-mysql-results/#findComment-1022231 Share on other sites More sharing options...
Redlightpacket Posted March 6, 2010 Share Posted March 6, 2010 Try this, this way works for me $query = "SELECT * FROM Cards"; $result = mysql_query($query) or die("Query failed: " . mysql_error()); while ($row = mysql_fetch_assoc($result)) { //Prints the id numbers in the table. The id numbers go from 1 and forever //You will need to set a primary key and it will be the primary id number in your mysql table echo $row['id']; //Prints row numbers } Link to comment https://forums.phpfreaks.com/topic/194313-how-to-number-mysql-results/#findComment-1022232 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.