Jump to content

how to count and display records?


New4You

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

Link to comment
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.
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.