Skip to main content
Participant
May 14, 2007
Answered

Dreamweaver/ php recordsets

  • May 14, 2007
  • 2 replies
  • 299 views
Hello,

I have a query which find featured products from the database. There are three in total. These products are then displayed in little boxes on the site, each with a different background colour. Usually, I would just repeat the region to show each product, but the background colour wouldnt change then.

What I wanted to do, was to say something like 'if this is row 1, then use this colour as the background to the box, if its row two, use this colour.. and so on.
Im ok at php, but by no means an expert so i need a bit of help on this one! any advice would be appreciated.

Thanks 🙂
This topic has been closed for replies.
Correct answer Newsgroup_User
MissKristy wrote:
> I have a query which find featured products from the database. There are three
> in total. These products are then displayed in little boxes on the site, each
> with a different background colour. Usually, I would just repeat the region to
> show each product, but the background colour wouldnt change then.

Create three style rules in your style sheet. Name them product1,
product2, and product3.

Just ahead of the repeat region code, insert this little code block
outside the do... while loop:

<?php $counter = 1; ?>

Then inside the repeat region itself, use the counter to build three
unique IDs for the rows:

<tr id="product<?php echo $counter++; ?>">... </tr>

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

2 replies

Participant
May 14, 2007
Perfect. That worked great!

Thanks so much :)
Newsgroup_UserCorrect answer
Inspiring
May 14, 2007
MissKristy wrote:
> I have a query which find featured products from the database. There are three
> in total. These products are then displayed in little boxes on the site, each
> with a different background colour. Usually, I would just repeat the region to
> show each product, but the background colour wouldnt change then.

Create three style rules in your style sheet. Name them product1,
product2, and product3.

Just ahead of the repeat region code, insert this little code block
outside the do... while loop:

<?php $counter = 1; ?>

Then inside the repeat region itself, use the counter to build three
unique IDs for the rows:

<tr id="product<?php echo $counter++; ?>">... </tr>

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