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! 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++; } 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); ?> 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]; 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! 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
Archived
This topic is now archived and is closed to further replies.