pancgom Posted February 5, 2008 Share Posted February 5, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/89507-php-and-mysql-table-formatting/ Share on other sites More sharing options...
Barand Posted February 5, 2008 Share Posted February 5, 2008 Create a style definition in the html head section <style> th { background-color: #CCC; } </style> Quote Link to comment https://forums.phpfreaks.com/topic/89507-php-and-mysql-table-formatting/#findComment-458473 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.