| | |
PHP and MYSQL table formatting
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 26
Reputation:
Solved Threads: 0
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>
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 Syntax (Toggle Plain Text)
<?php echo "<table border=1>"; echo "<th bgcolor=\"red\">test</th>"; echo "</table>"; ?>
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*
*PM asking for help will be ignored*
"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
ok?
just replace print "<th>".mysql_field_name($record_set,$c)."</th>";
with
php Syntax (Toggle Plain Text)
print "<tr><td bgcolor='red'><font size='2'>".mysql_field_name($record_set,$c)."</font></td></tr>";
ok?
•
•
Join Date: Jan 2008
Posts: 26
Reputation:
Solved Threads: 0
•
•
•
•
php Syntax (Toggle Plain Text)
<?php echo "<table border=1>"; echo "<th bgcolor=\"red\">test</th>"; echo "</table>"; ?>
Hope that helps.
IT WORKED..THANKS A LOT
•
•
Join Date: Jan 2008
Posts: 26
Reputation:
Solved Threads: 0
•
•
•
•
"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
php Syntax (Toggle Plain Text)
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...
![]() |
Similar Threads
- How insert image into mysql database and retrieve (PHP)
- HTML is trimming my spaces help (PHP)
- PHP MySQL problem (PHP)
- mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
- Which technologies for optimum site? (IT Professionals' Lounge)
- Struggling with Captcha (PHP)
- submiting info into a database for retrieval! (PHP)
- Complete List of Mysql Commands for PHP tokenization script. (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP OOP Question
- Next Thread: executing unix commands from php
| Thread Tools | Search this Thread |
apache api array basic beginner binary broken cache cakephp checkbox class cms code computing confirm cron curl customizableitems database date delete display dynamic echo email error external file files filter folder form forms forum function functions gc_maxlifetime google headmethod host howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction memmory memory menu mlm multiple mysql navigation oop parsing paypal pdf php phpmysql problem query question radio random recursion remote script search select server sessions sms snippet source space sql syntax system table thesishelp trouble tutorial update upload url validator variable video web youtube






