【问题标题】:Mouse Over - Show MYSQL Data鼠标悬停 - 显示 MYSQL 数据
【发布时间】: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。我正在尝试找出简单的方法。谢谢您的帮助。我花了一段时间才达到显示数据和设置所有表的关系的地步。

【问题讨论】:

    标签: php html mysql ajax


    【解决方案1】:

    您可以使用工具提示在鼠标悬停时显示数据库中的结果

    <a href="#" data-toggle="tooltip" title=" <?php echo $data['location_name'].$data['location_email'];?> " > link </a>
    

    【讨论】:

      【解决方案2】:

      我认为您需要一些 Ajax 脚本来直接在悬停框中打印这些信息。据我所知,没有 PHP 函数可以满足您的要求。

      【讨论】:

      • 不幸的是没有。无论如何,这种投反对票的可悲功能使我不再参与该网站。
      【解决方案3】:

      让它工作,

      我使用了以下网址。效果很好

      http://hscripts.com/tutorials/html/tooltip.php
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-06-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-06
        • 1970-01-01
        • 2012-09-21
        • 1970-01-01
        相关资源
        最近更新 更多