Skip to main content
October 22, 2006
Question

PHP CurrentRow

  • October 22, 2006
  • 2 replies
  • 590 views
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 has been closed for replies.

2 replies

October 25, 2006
Thank you David so much for all of your help.

Thank you,
AdonaiEchad
Inspiring
October 22, 2006
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/
October 22, 2006
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