redarrow Posted October 19, 2006 Share Posted October 19, 2006 does this look correct to you as i am learning how to use for loops to produce tables cheers.[code]<?phpecho"<html><body>";$list1=array(green =>"red", red => "green", pink => "yellow", yellow => "pink",pink => "grey",grey => "orange", orange => "brown",brown => "blue");foreach($list1 as $b => $a){echo"<table align='center' border='4' bordercolor='black'>";for($i=0; $i< 1; $i++){echo "<tr><td width='60' align='center' bgcolor='$a'>$a</tr></td><td width='60' align='center'bgcolor='$b'>$b</td>";} } echo"</table></body></html>";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24407-tables/ Share on other sites More sharing options...
.josh Posted October 19, 2006 Share Posted October 19, 2006 maybe if you explained exactly what you were trying to do here.. cuz i'm looking at your script and there's no apparent sense to it. you are missing a < tr > .. < /tr > in your echo inside your for loop though Quote Link to comment https://forums.phpfreaks.com/topic/24407-tables/#findComment-111059 Share on other sites More sharing options...
redarrow Posted October 19, 2006 Author Share Posted October 19, 2006 I am trying to learn all the possabiltys with tables and for loops so that i dont need to hard code html.if you got any examples with tables and for loops then post it m8 cheers. Quote Link to comment https://forums.phpfreaks.com/topic/24407-tables/#findComment-111061 Share on other sites More sharing options...
Daniel0 Posted October 19, 2006 Share Posted October 19, 2006 [code]<?php$rows = 2;$cols = 5;$data = array( array( '1,1','1,2','1,3','1,4','1,5' ), array( '2,1','2,2','2,3','2,4','2,5' ), );echo "<table border='1'>\n";for($row=0; $row<$rows; $row++){ echo "\t<tr>\n"; for($col=0; $col<$cols; $col++) { echo "\t\t<td>{$data[$row][$col]}</td>\n"; } echo "\t</tr>\n";}echo "</table>";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24407-tables/#findComment-111072 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.