Zyncmaster2006 Posted September 22, 2006 Share Posted September 22, 2006 hi can you help me guys. I don't know how to create a script to put a line number on every data I display using mysql_fetch_array. U knw something like this :1. Adrian2. Manny3. HenryCan you guys provide me a script or a tutorial?? thnx Link to comment https://forums.phpfreaks.com/topic/21633-line-numbers-or-row-numbers/ Share on other sites More sharing options...
AdRock Posted September 22, 2006 Share Posted September 22, 2006 I had to do something similar to what you want to do and found using the id field was not an option so i used an ordered listIt gets all the data from the database and adds 1 to the counter so i get what you want to do. My OL id is just the style i applied to each name/number[code]<?phpinclude_once("includes/connection.php");$counter = 1;$q = mysql_query("SELECT id, title FROM news ORDER BY id DESC LIMIT 5"); echo "<OL id=\"blah\">"; while($articles = mysql_fetch_object($q)) { echo "<LI><a class=\"one\" href=\"/news/".$counter."\">".$articles->title."</a></LI>"; $counter = $counter + 1;} echo"</OL>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/21633-line-numbers-or-row-numbers/#findComment-96537 Share on other sites More sharing options...
trq Posted September 22, 2006 Share Posted September 22, 2006 You can replace this...[code=php:0]$counter = $counter + 1;[/code]with...[code=php:0]$counter++[/code] Link to comment https://forums.phpfreaks.com/topic/21633-line-numbers-or-row-numbers/#findComment-96546 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.