因此,此 PHP 代码将在网页上打印我的数据库中的所有表数据。
<?php
$hostname = '127.0.0.1:3306';
$dbname = 'login'; // Your database name.
$username = 'root'; // Your database username.
$password = ''; // Your database password. If your database has no password, leave it empty.
mysql_connect($hostname, $username, $password) or DIE('Connection to host is failed, perhaps the service is down!');
mysql_select_db($dbname) or DIE('Database name is not available!');
$query="SELECT * FROM markers";
$result=mysql_query($query);
$fields_num = mysql_num_fields($result);
echo "<table border='2'><tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<td>{$field->name}</td></div>";
}
echo "</tr>\n";
// printing table rows
while($row = mysql_fetch_row($result))
{
echo "<table>";
echo "<tr>";
echo "<td>$row[0]</td>";
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
echo "<td>$row[3]</td>";
echo "</tr>\n";
echo "</table></div>";
}
?>
但本质上它所做的就是这样。它的格式不正确。它是这样的。
我想做的就是把这张桌子准确地放在网页的中心,给它一些花哨的边框(弯曲的边缘,很棒的字体。)