Jump to content

tables.


redarrow

Recommended Posts


does this look correct to you as i am learning how to use for loops to produce tables cheers.

[code]

<?php

echo"<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]
Link to comment
https://forums.phpfreaks.com/topic/24407-tables/
Share on other sites

[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]
Link to comment
https://forums.phpfreaks.com/topic/24407-tables/#findComment-111072
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.