Hi Guys,

This is probably the most silliest of questions, i am still learning php and mysql :-| .

I have this code below which brings up data from the database and displays it, what i want to do is to give the table headers a bgcolor how do i insert it, i get a parse error when i try to introduce a bgcolor..

Can anyone help.

<table border="1" bordercolor="black" cellpadding="2" cellspacing="0" width="550">

{php}


$db_username=;
$db_password=;
$db_name=;

mysql_connect($db_connect,$db_username,$db_password);
mysql_select_db($db_name);
$record_set=mysql_query("SELECT * FROM dDdDdD");

for($c=0; $c<mysql_num_fields($record_set);$c++){


print "<th>".mysql_field_name($record_set,$c)."</th>";

}


while($record=mysql_fetch_row($record_set)){
print "<tr>";

for($c=0; $c<mysql_num_fields($record_set);$c++){
print "<td>".$record[$c]."</td>";

}
print "</tr>";
}

{/php}
</table>

<?php
echo "<table border=1>";
echo "<th bgcolor=\"red\">test</th>";
echo "</table>";
?>

Hope that helps.

"The "bgcolor", "height", "width", and "nowrap" attributes of the th element were deprecated in HTML 4.01." --w3schools.com

just replace print "<th>".mysql_field_name($record_set,$c)."</th>";
with

print  "<tr><td bgcolor='red'><font size='2'>".mysql_field_name($record_set,$c)."</font></td></tr>";

ok?

<?php
echo "<table border=1>";
echo "<th bgcolor=\"red\">test</th>";
echo "</table>";
?>

Hope that helps.

IT WORKED..THANKS A LOT

You are welcome!

"The "bgcolor", "height", "width", and "nowrap" attributes of the th element were deprecated in HTML 4.01." --w3schools.com

just replace print "<th>".mysql_field_name($record_set,$c)."</th>";
with

print  "<tr><td bgcolor='red'><font size='2'>".mysql_field_name($record_set,$c)."</font></td></tr>";

ok?

It worked...thanks a lot for the help...

Ok,cool!Just mark your thread as solved,ok?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.