Forum : CHECK IT OUT SOON PHP ARRAYS
Brief description  about Online courses   join in Online courses
View rupa vishwanathan iyer 's Profile

CHECK IT OUT SOON PHP ARRAYS

2) Using arrays create a table with one column, which lists all your favorite colors. Background of each table row should be same as the color named in the row.
3) Using arrays , create a two column table, that shows few states of India and capital cities of these states.PLZ GIVE ME A SAMPLE CODE FOR THESE TWO I AM NOT GETTING IT RIGHT.
Asked by rupa vishwanathan iyer | Apr 22, 2011 |  Reply now
Replies (3)
View rupa vishwanathan iyer 's Profile
both the codes are not working whatever i have written is being shown on screen plz check
Apr 25, 2011
View teacher siliconindia 's Profile

echo"<h2>2) Using arrays create a table with one column, which lists all your favorite colors. Background of each table row should be same as the color named in the row.</h2>";



$color[0]= 'Red';
$color[1]= 'Pink';
$color[2]= 'Orange';
$color[3]= 'Yellow';
$color[4]= 'Green';
$color[5]= 'Brown';
$color[6]= 'Violet';
$color[7]= 'Blue';
$color[8]= 'White';
$color[9]= 'Skyblue';
$color[10]= 'Maroon';

echo "<table border='1'>";

echo"<tr bgcolor='green'><th>FAVOURITE COLORS</th></tr>";


echo "<tr><td><p style=\"background-color:red\">";
echo $color[0];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:pink\">";
echo $color[1];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:orange\">";
echo $color[2];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:yellow\">";
echo $color[3];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:green\">";
echo $color[4];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:brown\">";
echo $color[5];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:violet\">";
echo $color[6];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:blue\">";
echo $color[7];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:white\">";
echo $color[8];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:skyblue\">";
echo $color[9];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:maroon\">";
echo $color[10];
echo "</p></td></tr>";

echo "</table>";






echo"<h2>3) Using arrays , create a two column table, that shows few states of India and capital cities of these states.</h2>";


$states_capital = array (

"Delhi" => "New Delhi",
"TamilNadu" => "Chennai",
"Karnataka" => "Bangalore",
"Andhra Pradesh" => "Hyderabad",
"Kerala" => "Thiruvananthapuram",
"Goa" => "Panaji",
"Maharashtra" => "Mumbai",
"Bihar" => "Patna",
"Haryana" => "Chandigarh",

);



echo "<table border='1' cellpadding='5'>";

echo"<tr bgcolor='green'><th>STATES</th><th>CAPITAL</th></tr>";


foreach($states_capital as $States=>$Capital)
{
echo "<tr bgcolor='yellow'><td>$States </td><td>$Capital</td></tr> ";

}



echo "</table>";
Apr 25, 2011
View teacher siliconindia 's Profile

echo"<h2>2) Using arrays create a table with one column, which lists all your favorite colors. Background of each table row should be same as the color named in the row.</h2>";



$color[0]= 'Red';
$color[1]= 'Pink';
$color[2]= 'Orange';
$color[3]= 'Yellow';
$color[4]= 'Green';
$color[5]= 'Brown';
$color[6]= 'Violet';
$color[7]= 'Blue';
$color[8]= 'White';
$color[9]= 'Skyblue';
$color[10]= 'Maroon';

echo "<table border='1'>";

echo"<tr bgcolor='green'><th>FAVOURITE COLORS</th></tr>";


echo "<tr><td><p style=\"background-color:red\">";
echo $color[0];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:pink\">";
echo $color[1];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:orange\">";
echo $color[2];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:yellow\">";
echo $color[3];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:green\">";
echo $color[4];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:brown\">";
echo $color[5];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:violet\">";
echo $color[6];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:blue\">";
echo $color[7];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:white\">";
echo $color[8];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:skyblue\">";
echo $color[9];
echo "</p></td></tr>";

echo "<tr><td><p style=\"background-color:maroon\">";
echo $color[10];
echo "</p></td></tr>";

echo "</table>";






echo"<h2>3) Using arrays , create a two column table, that shows few states of India and capital cities of these states.</h2>";


$states_capital = array (

"Delhi" => "New Delhi",
"TamilNadu" => "Chennai",
"Karnataka" => "Bangalore",
"Andhra Pradesh" => "Hyderabad",
"Kerala" => "Thiruvananthapuram",
"Goa" => "Panaji",
"Maharashtra" => "Mumbai",
"Bihar" => "Patna",
"Haryana" => "Chandigarh",

);



echo "<table border='1' cellpadding='5'>";

echo"<tr bgcolor='green'><th>STATES</th><th>CAPITAL</th></tr>";


foreach($states_capital as $States=>$Capital)
{
echo "<tr bgcolor='yellow'><td>$States </td><td>$Capital</td></tr> ";

}



echo "</table>";
Apr 25, 2011