Jump to content

Archived

This topic is now archived and is closed to further replies.

New4You

how to count and display records?

Recommended Posts

Hi there all,

Maybe its really simple, and Im gunna look stupid, but here goes anyway .... [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /]

I have a recorset that Im returning on my php page. I have a download site - it contains a 'Top 100 Downloads' page. This page lists all the top 100 records. I've got that part to work ok ...

But what I really want to do, is for each record displayed, also display a record number.

eg.

1. Download file A
2. Download file B
3. Download file C
4. Download file D
etc ...

Can someone please offer some help ?

Thanks all ! [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

Jay

Share this post


Link to post
Share on other sites
well, if you've already got it displaying the records, just set up an incrementer within the loop where you echo your results... something like this should work nicely:
[code]
$res = mysql_query($query); // whatever you're selecting
$count = 0;
while ($row = mysql_fetch_array($res)) {
  ++$count;
  echo "$count. $row['name']<br />\n";
}
[/code]

notice that with each loop, $count is being incremented to reflect the row number. that's really all you need.

Share this post


Link to post
Share on other sites
thanks obsidian

Two thumbs up to you mate ! [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]

I knew it would not be difficult for someone in the know such as yourself!

Thanks again - I'm looking forward to implementing into my site asap!!!

Cheers
Jamie

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.