PHP and MYSQL table formatting

Thread Solved

Join Date: Jan 2008
Posts: 26
Reputation: pancgom is an unknown quantity at this point 
Solved Threads: 0
pancgom pancgom is offline Offline
Light Poster

PHP and MYSQL table formatting

 
0
  #1
Feb 5th, 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>
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: PHP and MYSQL table formatting

 
0
  #2
Feb 5th, 2008
  1. <?php
  2. echo "<table border=1>";
  3. echo "<th bgcolor=\"red\">test</th>";
  4. echo "</table>";
  5. ?>

Hope that helps.
Last edited by nav33n; Feb 5th, 2008 at 3:09 am.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 567
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: PHP and MYSQL table formatting

 
0
  #3
Feb 5th, 2008
"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

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

ok?
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 26
Reputation: pancgom is an unknown quantity at this point 
Solved Threads: 0
pancgom pancgom is offline Offline
Light Poster

Re: PHP and MYSQL table formatting

 
0
  #4
Feb 5th, 2008
Originally Posted by nav33n View Post
  1. <?php
  2. echo "<table border=1>";
  3. echo "<th bgcolor=\"red\">test</th>";
  4. echo "</table>";
  5. ?>

Hope that helps.

IT WORKED..THANKS A LOT
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: PHP and MYSQL table formatting

 
0
  #5
Feb 5th, 2008
You are welcome!
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 26
Reputation: pancgom is an unknown quantity at this point 
Solved Threads: 0
pancgom pancgom is offline Offline
Light Poster

Re: PHP and MYSQL table formatting

 
0
  #6
Feb 5th, 2008
Originally Posted by ryan_vietnow View Post
"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

  1. 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...
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 567
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: PHP and MYSQL table formatting

 
0
  #7
Feb 5th, 2008
Ok,cool!Just mark your thread as solved,ok?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC