monkeypaw201 Posted February 8, 2008 Share Posted February 8, 2008 i need to have a number increase in a table for every row it displays... how can i do this? Quote Link to comment https://forums.phpfreaks.com/topic/90119-solved-incrementing-numbers/ Share on other sites More sharing options...
marcus Posted February 8, 2008 Share Posted February 8, 2008 $x = 1; while($row = mysql_fetch_assoc($res)){ echo $x . "<br>"; $x++; } Quote Link to comment https://forums.phpfreaks.com/topic/90119-solved-incrementing-numbers/#findComment-462085 Share on other sites More sharing options...
phpSensei Posted February 8, 2008 Share Posted February 8, 2008 To explain what mgallforever did: <?php $x = 1; // This is the increment number, and it starts at 1 while($row = mysql_fetch_assoc($res)){ // Since this is the while loop, the number of times the $x will go up by is when there is no more rows. echo $x . "<br>"; // Print out the Rows $x++; // Increment ++ to add +1 everytime } ?> You could do this without help mostly. If you think about the logic behind it. Quote Link to comment https://forums.phpfreaks.com/topic/90119-solved-incrementing-numbers/#findComment-462088 Share on other sites More sharing options...
Dada78 Posted February 8, 2008 Share Posted February 8, 2008 you could auto_increment that field in the table. Quote Link to comment https://forums.phpfreaks.com/topic/90119-solved-incrementing-numbers/#findComment-462093 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.