Jump to content


Photo

tables.


  • Please log in to reply
3 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 October 2006 - 05:06 AM


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


<?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>";
?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 19 October 2006 - 05:30 AM

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
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 October 2006 - 05:35 AM

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.

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 October 2006 - 06:38 AM

<?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>";
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users