note 31552 deleted from function.mysql-result by aidan
| From: | aidan@php.net | Date: | Fri, 09 Sep 2005 08:41:16 +0000 |
| Subject: | note 31552 deleted from function.mysql-result by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-94946@lists.php.net to get a copy of this message | ||
Note Submitter: omtelcom at lycos dot es
----
|¯OMTELCOM_| from Tunja - Colombia!!
If you like to see your results in a table:
<html>
<title>|¯OMTELCOM_| Show a MySQL Query in a HTML Table |¯OMTELCOM_|</title>
<body>
<?php
$link = mysql_connect("localhost", "nobody");
mysql_select_db("mybd", $link);
$qry = mysql_query("SELECT * FROM agenda", $link);
?><table border="1" width="100%"><tr><?php
if (mysql_num_rows($qry) > 0) {
for ($i = 0; $i<mysql_num_fields($qry); $i++) {
echo "<td align=center><strong>" . mysql_field_name($qry, $i) .
"</td>";
}
}
?></tr><?php
if (mysql_num_rows($qry) > 0) {
for ($j = 0; $j<mysql_num_rows($qry); $j++) {
?><tr><?php
for ($k = 0; $k<mysql_num_fields($qry); $k++) {
echo "<td align=center>" . mysql_result($qry,$j, $k) . "</td>";
}
?></tr><?php
}
}
?></table>
</body>
</html>