close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

alternating background div

Thread began 6/14/2021 2:01 pm by JBWebWorks | Last modified 6/14/2021 7:34 pm by Ray Borduin | 165 views | 2 replies |

JBWebWorks

alternating background div

Have mysqli repeat region for a div#eventsdiv. here is code

<?php
$wa_startindex = 0;
while(!$rs_events->atEnd()) {
$wa_startindex = $rs_events->Index;
?>
<div id="eventsdiv" align="center"><?php /*START_PHP_SIRFCIT*/ if ($rs_events->getColumnVal("events_photo")!=""){ ?><img width="20%" src="images/events/<?php echo($rs_events->getColumnVal("events_photo")); ?>" /><?php } else echo''; /*END_PHP_SIRFCIT*/ ?> <br />
<h2><?php echo($rs_events->getColumnVal("events_name")); ?></h2>
<table width="60%" border="1" cellpadding="10"><tr><td width="50%" align="center" valign="top"><?php echo($rs_events->getColumnVal("events_time")); ?></td><td width="50%" align="center" valign="top"><?php echo($rs_events->getColumnVal("events_location")); ?></td></tr></table><br />
<div id="eventdescribe"><?php echo($rs_events->getColumnVal("events_description",false)); ?></div><br />
<br /><br />

</div>
<?php
$rs_events->moveNext();
}
$rs_events->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?>


Want the divs to alternate background color from #76323f to #d7cec7

What code do i need to add?

Sign in to reply to this post

Ray BorduinWebAssist

You could wrap it all in a div like:

<div id="altbg">
[your repeat code here]
</div>

Then use CSS like:
<style>
#altbg div:nth-child(even) {background: #76323f}
#altbg div:nth-child(odd) {background: #d7cec7}
</style>

Sign in to reply to this post
Did this help? Tips are appreciated...

JBWebWorks

That worked. Thanks Ray.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...