logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 08-10-2012, 10:34 PM   #1
greg.farmer
 
Join Date: Jan 2012
Posts: 11
Default Alternate Row colours

Hi Everyone, just wondering if anyone may be able to help.

Sorry if this is the wrong section.

I am not a fluent coder and have built a website for work in PHP using phpmyadmin. I usually do what I need in dreamweaver 4 and then study the code after to see how it is made up.

I have included a dynamic table and am needing to set alternate rows colours. I have trawled the web and not found anything either for what I need or that I understand. Is there a simple way in dreamweaver cs4 to do this.

I found this http://www.dreamweaverclub.com/forum...=alternate+row but it didn't seem to work for me.

Super grateful of your help

Greg

Last edited by greg.farmer; 08-10-2012 at 10:35 PM.. Reason: Update
greg.farmer is offline   Reply With Quote
Old 08-11-2012, 12:51 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

it should. do you mean its not because you used dreamweaver to create record sets?
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 08-11-2012, 01:02 AM   #3
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

try this. edit the connections to your own, I used as DW for this
edit table and field names

Code:
<?php require_once('Connections/???.php'); mysql_select_db($database_???, $????);


$sql = "SELECT * FROM `table` ORDER BY field1 DESC Limit 15";
$result = mysql_query($sql);
$row= mysql_fetch_array($result);
 ?>
 
<!DOCTYPE >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>alternate rows/title>
<style>
.color1{background-color:#fff;}
.color2{background-color:#999; color:#FFF;}
td a{color: #C03; font-weight:bold;}
</style>
</head>
<body> 

<table>
 
 <?php  
 
$no = 1; 
 
do { 
$divide = $no / 2; 
$detect = strstr($divide,'.');  

//check the IF statement in <tr> to echo the appropriate class
//if $detect is true then that is odd so echo color1 else echo color2
?>
 
<tr <?php if($detect){echo "class=\"color1\"";}else{echo "class=\"color2\"";} ?>>
    <td><?php echo "Ref ". $row['field1'];?></td>
 
    <td><?php echo $row['field2']?></td> 
    <td><?php echo $row['field3']?></td>
    <td>  <?php echo  $row['field4']?></td> 
  </tr>
 
  <?php   
$no++; //<< increment count. 
}while  ($row = mysql_fetch_array($result))    
?> 
<table>
</body>
</html>
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 08-13-2012, 09:54 AM   #4
greg.farmer
 
Join Date: Jan 2012
Posts: 11
Default

Thanks, i'll give this a try. I did make the record set in DW. I used the GUI rather then coded it though.
greg.farmer is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:53 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com