【发布时间】:2016-05-12 13:19:42
【问题描述】:
到目前为止,我有以下代码:
<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "password";
$mysql_database = "test_db";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Oops some thing went wrong");
mysql_select_db($mysql_database, $bd) or die("Oops some thing went wrong");// we are now connected to database
$location = "";
$result = mysql_query("SELECT * FROM assets natural join loc_admin natural join id_info WHERE assets.id_location LIKE '$location%'");
echo '<table border=1px>'; // opening table tag
echo'<th>ID</th><th>ID_Location</th><th>Room</th><th>Device Type</th><th>Model</th><th>Version</th><th>Firmware</th><th>Manufacturer</th><th>Tech_Name</th>'; //table headers
while($data = mysql_fetch_array($result))
{
// we are running a while loop to print all the rows in a table
echo'<tr>'; // printing table row
echo '<td>'.$data['idassets'].'</td><td>'.$data['id_location'].'</td><td>'.$data['room_number'].'</td><td>'.$data['device'].'</td><td>'.$data['model'].'</td><td>'.$data['version'].'</td><td>'.$data['firmware'].'</td><td>'.$data['manufacturer'].'</td><td>'.$data['tech_name'].'</td>'; // we are looping all data to be printed till last row in the table
echo'</tr>'; // closing table row
}
echo '</table>'; //closing table tag
?>
效果很好——我可以在 3 个表中的每一个中显示我的所有信息。
目前,我只显示上述内容,但我想将鼠标悬停在名为 id_info 的数据库中显示数据(站点信息),并且当我将鼠标悬停时,其中有带有 location_name、location_email 等的行的初始 id_location。我正在尝试找出简单的方法。谢谢您的帮助。我花了一段时间才达到显示数据和设置所有表的关系的地步。
【问题讨论】: