pixeltrace Posted September 19, 2007 Share Posted September 19, 2007 hi, i need to list something which will be driven from mysql database and the output that i want to have is something like this. 1. item1 2. item 2 3. item3 4. item5 ......... how can i generate the numbers 1. - 4. ......? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/69940-solved-how-to-have-number-count-beside-each-item/ Share on other sites More sharing options...
BlueSkyIS Posted September 19, 2007 Share Posted September 19, 2007 $i = 1; while ($row = mysql_fetch_array($result)) { echo "$i. ".$row['var1']; $i++; } Quote Link to comment https://forums.phpfreaks.com/topic/69940-solved-how-to-have-number-count-beside-each-item/#findComment-351300 Share on other sites More sharing options...
darkfreaks Posted September 19, 2007 Share Posted September 19, 2007 <?php $count= array($_POST[item1],$_POST[item2],$_POST[item3],$_POST[item4]); echo count($count); ?> Quote Link to comment https://forums.phpfreaks.com/topic/69940-solved-how-to-have-number-count-beside-each-item/#findComment-351303 Share on other sites More sharing options...
tibberous Posted September 19, 2007 Share Posted September 19, 2007 function index($reset = FALSE){ static $_ = 1; if($reset){ $_ = 2; return 1; } else { return $_++; } } while ($row = mysql_fetch_array($result)) echo index().$row[0]; Quote Link to comment https://forums.phpfreaks.com/topic/69940-solved-how-to-have-number-count-beside-each-item/#findComment-351305 Share on other sites More sharing options...
pixeltrace Posted September 19, 2007 Author Share Posted September 19, 2007 thanks! $i works! Quote Link to comment https://forums.phpfreaks.com/topic/69940-solved-how-to-have-number-count-beside-each-item/#findComment-351314 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.