Jump to content


Line numbers or row numbers

  • Please log in to reply
2 replies to this topic

#1 Zyncmaster2006

  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 22 September 2006 - 07:33 AM

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.  Adrian
2.  Manny
3.  Henry

Can you guys provide me a script or a tutorial?? thnx

#2 AdRock

  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 22 September 2006 - 07:39 AM

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 list
It 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

$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;

If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#3 trq

  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 22 September 2006 - 08:09 AM

You can replace this...

$counter = $counter + 1;



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users