CanMan2004 Posted December 11, 2006 Share Posted December 11, 2006 Hi allI have a quick question.I have a bit of php code which looks like;<?while($rows = mysql_fetch_array($result)){print $rows['title'];print "<br>";}?>This outputs 3 words currentlyWelcomeHappenSwitchIs there a way to put a number before each result, so it would look like1: Welcome2: Happen3: SwitchSo it puts numbers before each result, numbers should run from 1 upwards, for example, a large result would be1: Welcome2: Happen3: Switch4: Holiday5: Water6: Always7: PoolCan this be done?Any help would be aceThanks in advanceDave Link to comment https://forums.phpfreaks.com/topic/30229-numbered-results/ Share on other sites More sharing options...
HuggieBear Posted December 11, 2006 Share Posted December 11, 2006 Try this:[code]<?php$i = 1; // default start valuewhile($rows = mysql_fetch_array($result)){ echo "$i: {$rows['title']}<br>\n"; $i++; // increment the counter by 1}?>[/code]RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/30229-numbered-results/#findComment-138977 Share on other sites More sharing options...
CanMan2004 Posted December 11, 2006 Author Share Posted December 11, 2006 thank you, thank you, thank you Link to comment https://forums.phpfreaks.com/topic/30229-numbered-results/#findComment-138978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.