Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

mysql_fetch_row()

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

mysql_fetch_row()

Postby jacquesy » Tue Feb 04, 2003 2:22 pm

I am bringing records from a database to my page using mysql_fetch_row() to display a top 5 list.

The problem is I want to print out the postion at the start of each line, i.e.
1. some-name
2. some-name
3. some-name
4. some-name
5. some-name

I can't work out how to do this using while as it will print out the same value on each line! Can anybody help?

Thanks!
jacquesy
New php-forum User
New php-forum User
 
Posts: 12
Joined: Tue Jan 21, 2003 2:27 pm

Postby Joan Garnet » Tue Feb 04, 2003 4:35 pm

Try this one:
Code: Select all
$row = mysql_fetch_row($result);
for($i=0;$i<sizeof($row);$i++){
   echo "- ".$i.": ".$row[$i]."<br>";
}
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.