SunQuest
 
           PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old October 7th, 2002, 07:00 PM
adrian adrian is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 20 adrian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Table layout appearance with php help

i've wrote bog standard php code for putting MySql data into a table which is as follows

PHP Code:
 $i=0;

while (
$i $num) {

$date=mysql_result($result,$i,"date");
$hometeam=mysql_result($result,$i,"hometeam");
$scoredhome=mysql_result($result,$i,"scoredhome");
$scoredaway=mysql_result($result,$i,"scoredaway");
$awayteam=mysql_result($result,$i,"awayteam");
$matchreport=mysql_result($result,$i,"matchreport");
$notes=mysql_result($result,$i,"notes");
$yr=strval(substr($date,2,2));   
$mo=strval(substr($date,5,2));   
$da=strval(substr($date,8,2));
?>
<tr> 
      <td align="center"><font color="#FFFFFF" size="1" face="verdana"><? echo "$da-$mo-$yr"?></font></td>
      <td align="center"><font color="#FFFFFF" size="1" face="verdana"><? echo "$hometeam"?></font></td>      
      <td align="center"><font color="#FFFFFF" size="1" face="verdana"><? if ($scoredhome 99) {echo "$scoredhome";} else {echo " ";} ?></font></td>
      <td align="center"><font color="#FFFFFF" size="1" face="verdana"><? if ($scoredaway <99) {echo "$scoredaway";}else {echo " ";} ?></font></td>   
      <td align="center"><font color="#FFFFFF" size="1" face="verdana"><? echo "$awayteam"?></font></td>
      <td align="center"><font color="#FFFFFF" size="1" face="verdana"><? if ($notes !="") {echo "$notes";} else {echo " ";} ?></font></td> 
      <td align="center"><font color="#FFFFFF" size="1" face="verdana"></font></td>
      </tr>
      <?


++$i;    
}
MYSQL_CLOSE();

?>   </table> 



What i want to do is change the backgound colour of the table rows every other row to make the data easier to read but after trying several ways i'm stuck and hoping someone here can help me with this problem. What i mean is i want the first row of the table to be a dark grey, the next row to be a lighter grey, the next row to be dark grey and so on. Thanks for your time.



Edit: Please enclose code within "php" & "/php" brackets.

Last edited by FrankieShakes : October 7th, 2002 at 08:36 PM.

Reply With Quote
  #2  
Old October 7th, 2002, 07:11 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
use this following line of code

$bgcolor = ($bgcolor == "light grey" ? "dark grey": "light grey");

then place $bgcolor in each <tr> tag

Reply With Quote
  #3  
Old October 7th, 2002, 07:27 PM
adrian adrian is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 20 adrian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks alot Ben that's worked great. Much appreciated.

Reply With Quote
  #4  
Old October 7th, 2002, 08:04 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
no problems

Reply With Quote
  #5  
Old October 12th, 2002, 07:42 PM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
on an anal retentive note

try not to use the font tag , it's deprecated in html 4.01. try using style in your table data tags, ex.
PHP Code:
<td style="color:white; font-size:1; font-family:verdana\">$celldata</td> 

Reply With Quote
  #6  
Old October 12th, 2002, 07:42 PM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
ignore that \"

should just be "
before ben corrects me

Reply With Quote
  #7  
Old October 13th, 2002, 07:24 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
damm, i could always edit your post ehehe

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Table layout appearance with php help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway