Author Topic: Line numbers or row numbers  (Read 349 times)

0 Members and 1 Guest are viewing this topic.

Offline Zyncmaster2006Topic starter

  • Irregular
  • Posts: 8
    • View Profile
Line numbers or row numbers
« on: September 22, 2006, 03:33:57 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

Offline AdRock

  • Devotee
  • Posts: 861
    • View Profile
Re: Line numbers or row numbers
« Reply #1 on: September 22, 2006, 03:39:31 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

Code: [Select]
<?php
include_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>";
?>
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: Line numbers or row numbers
« Reply #2 on: September 22, 2006, 04:09:22 AM »
You can replace this...


$counter 
$counter 1;


with...


$counter
++