我正在尝试使用 php 从 mysql 表中提取数据,这是我的代码。此代码位于 html 正文中。
<?php
// Connects to your Database
mysql_connect("localhost", "xxxxx", "Hxxxxxx") or die(mysql_error());
mysql_select_db("core_config") or die(mysql_error());
$data = mysql_query("SELECT * FROM vrf group by vrf") or die(mysql_error());
Print "<table border cellpadding=3>";
while ( $info = mysql_fetch_array ( $data )) {
Print "<tr>";
Print "<th>Name:</th> <td>".$info['Switch'] . "</td> ";
Print "<th>Name:</th> <td>".$info['vlan'] . "</td> ";
Print "<th>Name:</th> <td>".$info['ip_address'] . "</td> ";
Print "<th>Pet:</th> <td>".$info['vrf'] . " </td></tr>";
}
Print "</table>";
?>
由于某种原因,当我在浏览器中执行 html 时,我没有得到想要的结果。我得到以下输出。
"; while($info = mysql_fetch_array( $data )) { Print ""; Print "Name: ".$info['Switch'] . " "; Print "Name: ".$info['vlan'] . " "; Print "Name: ".$info['ip_address'] . " "; Print
"Pet: ".$info['vrf'] . " "; } Print ""; ?>
我已经进行了广泛的研究,但我似乎无法让它发挥作用,请帮忙。