almightyegg Posted April 5, 2007 Share Posted April 5, 2007 How can I make it auto number something in a while loop like: while($jnfw){ echo "[AUTO NUMBER]. $jnfw[blah]"; } That would show: 1. SOme value 2. Some value 3. Some value etc... I know I'm asking for a lot of help today but I'm trying to push my project forward Any help is greatly received and thanks in advance Link to comment https://forums.phpfreaks.com/topic/45718-solved-numbering-within-a-loop/ Share on other sites More sharing options...
papaface Posted April 5, 2007 Share Posted April 5, 2007 would: while($jnfw){ echo rand() . $jnfw[blah]; } work? Link to comment https://forums.phpfreaks.com/topic/45718-solved-numbering-within-a-loop/#findComment-222082 Share on other sites More sharing options...
almightyegg Posted April 5, 2007 Author Share Posted April 5, 2007 nope, no joy Link to comment https://forums.phpfreaks.com/topic/45718-solved-numbering-within-a-loop/#findComment-222086 Share on other sites More sharing options...
hitman6003 Posted April 5, 2007 Share Posted April 5, 2007 would: while($jnfw){ echo rand() . $jnfw[blah]; } work? Would put a random number before each entry...I think he wants a sequential number... $i = 0; while($jnfw){ echo ++$i . $jnfw[blah]; } Link to comment https://forums.phpfreaks.com/topic/45718-solved-numbering-within-a-loop/#findComment-222087 Share on other sites More sharing options...
almightyegg Posted April 5, 2007 Author Share Posted April 5, 2007 $i = 0; while($jnfw){ echo ++$i . $jnfw[blah]; } echo "<td>++$i . $clutch[name]</td><td>$clutch[id]</td>"; all that does is: ++0 . Group Name ++0 . Group Name2 etc... ??? and I did put the $i = 0; in and before the while starts. Link to comment https://forums.phpfreaks.com/topic/45718-solved-numbering-within-a-loop/#findComment-222091 Share on other sites More sharing options...
hitman6003 Posted April 5, 2007 Share Posted April 5, 2007 I don't think php will parse the increment operator when it's inside of quotes... echo "<td>" . $i++ . " " . $clutch[name] . "</td><td>" . $clutch[id] . "</td>"; Link to comment https://forums.phpfreaks.com/topic/45718-solved-numbering-within-a-loop/#findComment-222097 Share on other sites More sharing options...
almightyegg Posted April 5, 2007 Author Share Posted April 5, 2007 Ohh! It works! Although it starts at 0...do I just change $i = 1; to make it start from one? Link to comment https://forums.phpfreaks.com/topic/45718-solved-numbering-within-a-loop/#findComment-222100 Share on other sites More sharing options...
papaface Posted April 5, 2007 Share Posted April 5, 2007 yes Link to comment https://forums.phpfreaks.com/topic/45718-solved-numbering-within-a-loop/#findComment-222104 Share on other sites More sharing options...
almightyegg Posted April 5, 2007 Author Share Posted April 5, 2007 Cheers all done with that thanks Link to comment https://forums.phpfreaks.com/topic/45718-solved-numbering-within-a-loop/#findComment-222116 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.