New4You Posted May 22, 2006 Share Posted May 22, 2006 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 A2. Download file B3. Download file C4. Download file Detc ...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 Quote Link to comment https://forums.phpfreaks.com/topic/10180-how-to-count-and-display-records/ Share on other sites More sharing options...
obsidian Posted May 22, 2006 Share Posted May 22, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/10180-how-to-count-and-display-records/#findComment-37943 Share on other sites More sharing options...
New4You Posted May 23, 2006 Author Share Posted May 23, 2006 thanks obsidianTwo 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!!!CheersJamie Quote Link to comment https://forums.phpfreaks.com/topic/10180-how-to-count-and-display-records/#findComment-38116 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.