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 Quote Link to comment 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] Quote Link to comment 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] Quote Link to comment 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.