Is my syntax for php font correct?

praveen

New member
<? php
echo "<font color: 'red'>";
echo "<table border='1' width='700'><tr>";

for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<td>{$field->name}</td>";
}
echo"</font>";
?>
i wrote the code like this to get all the rows displayed be in red color.
But it is not effecting the table..
it is not filling with any color.
so please help me.
 
<?
echo "<table border=\"1\" width=\"700\"><tr>";
while($field = mysql_fetch_assoc($result){
extract($field);
echo "<td><font color=\"red\">$field->$filed_name</font></td></tr></table>";
}
?>
 
First of all it will probably help you to understand any of that stuff you are echoing isn't PHP it's html.

It's also out of date and out of standard, html.

You should be using styles instead.

What you're probably looking for (if you were going to use old standards) is this


<?php
(delete the font color unless you were trying to change the color of your text)

echo "<table border='1' width='700'><tr bgcolor='red'>";

however the proper way to do this is

echo "<table border='1' width='700'><tr style="background:red;">";


If you really want to be in standard, you shouldn't even Reference appearance in this file and instead include an external css file in the header of your document and set up a css selector like this


td {
width:700px;
border-width:1px;
}

tr {
background-color:red'
}
 
<? php
echo "<font color: 'red'>";
echo "<table border='1' width='700'><tr>";

for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<td>{$field->name}</td>";
}
echo "</tr>";
echo"</font>";
?>

I expect this would solve your problem.
 
Back
Top