RE: Stuck with HTML for MySQL Output
| From: | Rich, Adam J. | Date: | Sat, 11 Aug 2001 22:49:11 +0000 |
| Subject: | RE: Stuck with HTML for MySQL Output | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-11254@lists.php.net to get a copy of this message | ||
Sara,
I would do it like this:
<?
$link = mysql_pconnect ("localhost", "xxx", "xxxx") or exit();
mysql_select_db ("aokcc") or exit();
$fields = mysql_list_fields("aokcc", "handicap_results", $link);
$result = mysql_query ("select * from handicap_results") or exit ();
$num_rows = mysql_num_rows ($result);
print "<b>$num_rows games have been played in the League thus
far.</b><p>";
print "<table border=1 bgcolor=#000099>\n";
print "<tr>\n";
foreach ($fields as $fieldname) {
print "<TH>$fieldname</TH>\n";
}
print "</tr>\n";
while ($a_row = mysql_fetch_row ($result)) {
print "<tr>\n";
foreach ($fields as $fieldname) {
print "<TD>$a_row[$fieldname]</TD>\n";
}
print "<tr>\n";
}
print "</table>\n";
?>
Good Luck,
Adam
-----Original Message-----
From: Red [mailto:mightyred34@hotmail.com]
Sent: Saturday, August 11, 2001 8:38 AM
To: php-db@lists.php.net
Subject: Stuck with HTML for MySQL Output
Hi
I have a very simple query to my mysql dbase which returns the data ok. But
I can't get the html to work properly. I can change the bg color, but I
can't change the font, or font colour, and can't find anything in my book
which will help me.
Can anyone help please?
Secondly, how do I get Column titles for my database output? I have tried
everything and can't work it out. I did put a select x as y from
handicap_results in the sql query, but that still only producted the output
without any column titles.
BTW I am very new to php and sql, have two great book, but I'm having
trouble applying basic php theory which I kind of understand when I
introduce sql outputs!
Here is my script:
<?
$link = mysql_pconnect ("localhost", "xxx", "xxxx") or exit();
mysql_select_db ("aokcc") or exit();
$result = mysql_query ("select * from handicap_results") or exit ();
$num_rows = mysql_num_rows ($result);
print "<b>$num_rows games have been played in the League thus
far.</b><p>";
print "<table border=1 bgcolor=#000099\n";
while ($a_row = mysql_fetch_row ($result))
{
print "<tr>\n";
foreach ($a_row as $field)
print "\t<td>$field</td>\n";
print "<tr>\n";
}
print "</table>\n";
?>
Thanks in anticipation
Regards
Sara