Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

PHP CurrentRow

Guest
Oct 21, 2006 Oct 21, 2006

Copy link to clipboard

Copied

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
TOPICS
Server side applications

Views

568
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 22, 2006 Oct 22, 2006

Copy link to clipboard

Copied

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/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 22, 2006 Oct 22, 2006

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 22, 2006 Oct 22, 2006

Copy link to clipboard

Copied

AdonaiEchad wrote:
> <?php do { ?>
> <tr bgcolor="#D6EFF8"
> onmouseover="this.style.backgroundColor='#98B6D1'"
> onmouseout="this.style.backgroundColor='#D6EFF8'">
> <td>Record Count </td>

<?php $counter = 1; ?>
<?php do { ?>
<tr bgcolor="#D6EFF8"
onmouseover="this.style.backgroundColor='#98B6D1'"
onmouseout="this.style.backgroundColor='#D6EFF8'">
<td>Record Count: <?php echo $counter++; ?></td>


--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 24, 2006 Oct 24, 2006

Copy link to clipboard

Copied

LATEST
Thank you David so much for all of your help.

Thank you,
AdonaiEchad

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines