By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,644 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

Dynamic Data Layout

P: 7
Hi there,

I apologise if I'm posting in the wrong section - I Have absolutely no idea how my problem is resolved.

I have a recordset that queries my SQL data base the the results are displayed in a list - all normal so far.

What I want is insert a line between all the products that my SQL query displays and/or have each one in an alternative coloured background.

How is this done?
Thanks for any help given!
Nov 18 '08 #1
Share this Question
Share on Google+
5 Replies

P: 88
It's very easy if I get it correct. The proper HTML element to use should be a list (ul for unordered lists).

You can style you list with CSS (Insert margins between lits items, change backgrounds etc.).

For alternative background colors you may use classes. Here is an example:
<li class="odd">item 1</li>
<li class="even">item 2</li>
<li class="odd">item 3</li>

Styles for classes above:
Expand|Select|Wrap|Line Numbers
  1. odd {background:#ccc;}
  2. even {background:#ddd;}
Nov 18 '08 #2

P: 7
Thanks for the post serdar but styling is pages is really not my strong point and um unsure how to implement your code into my Sql results.

Can you please elaborate on how I insert lines between my results.

Thanks once again.
Nov 19 '08 #3

P: 88
Okay, which scripting language (PHP, ASP, JSP, etc.) are you using to query your database?
Nov 19 '08 #4

P: 7
Hi, Im using PHP in dreamweaver CS3
Nov 19 '08 #5

P: 88
Here is a sample php script, upload it to your server and test:


//this is a sample result set, you should replace it with your SQL query results
$results=array("result 1", "result 2", "result 3", "result 4", "result 5");


foreach ($results as $r) {
if ($odd) {$listClass='odd';}
else {$listClass='even';}
$list.='<li class="'.$listClass.'">'.$r.'</li>';


li {margin:10px 0;}
.odd {background:#ccc;}
.even {background:#ddd;}
<?php echo $list; ?>
Nov 19 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.