Skip to main content
Oct 22, 2006 2:39 AM UTC
Question

PHP CurrentRow

I have been trying to find out how to do a PHP "CurrentRow". I know in Coldfusion if you have so many records lets say 5 records it lists as the following below...

Rec | Name |
---------------------
1 | George |
2 | Fred |

Is there a php funching like Coldfusion that counts the rows for you as the "Rec" listing above.


Thank you,
AdonaiEchad
This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Oct 25, 2006 12:53 AM UTC
Thank you David so much for all of your help.

Thank you,
AdonaiEchad
Translate
Inspiring
Oct 22, 2006 11:18 AM UTC
AdonaiEchad wrote:
> Is there a php funching like Coldfusion that counts the rows for you as the
> "Rec" listing above.

There is no particular function, but you simply set a variable as a
counter and display that.

Dreamweaver uses a do... while loop to display a repeat region, so you
need to initialize the counter outside the loop, and then increment it
inside like this:

$counter = 1;
do {
// this is your repeat region
// use the following line to display and increment the counter
echo $counter++;
} while ($row_recordsetName = mysql_fetch_assoc($recordsetName));

The increment operator (++) adds 1 to the number after displaying it.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Oct 22, 2006 5:55 PM UTC
It is not working for me. My recordset is the following...
rsUsers
userID
userName
emailAddress
firstName
lastName
date
userType

Here is the code below to show how I have placed it. In the table data I had placed words of "Record Count" that is the area I believe where the count should begin.

Thank you for all of your help.

Thank you,
AdonaiEchad

Translate