<?php // Create connection $con=mysqli_connect("localhost","root","root"); mysql_select_db("test") or die( "Unable to select database"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } //***************************** table 1 detail *********** $query = "SELECT * FROM fraud WHERE a_number=" . $_GET["aNun_id"]; echo "<title>" . $_GET["aNun_id"] . "</title>"; echo "<table width='50%' border='5'> <tr> <th>Date & Time</th> <th>A Number</th> <th>B Number</th> <th>Status</th> </tr>"; $result=mysql_query($query) or die (mysql_error()); while($row=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['date'] . "</td>"; echo "<td>" . $row['a_number'] . "</td>"; echo "<td><a href='?bNun_id=".$row['b_number']."'>" . $row['b_number'] . "</a></td>"; echo "<td>" . $row['status'] . "</td>"; echo "</tr>"; } echo "</table>"; //***************************** table 2 detail *********** //Here i'm trying to use bNum_id in below query $query = "SELECT * FROM fraud WHERE b_number=" . $_GET["bNun_id"]; echo "<table width='50%' border='5'> <tr> <th>Date & Time</th> <th>A Number</th> <th>B Number</th> <th>Status</th> </tr>"; $result=mysql_query($query) or die (mysql_error()); while($row=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['date'] . "</td>"; echo "<td>" . $row['a_number'] . "</td>"; echo "<td>" . $row['b_number'] . "</td>"; echo "<td>" . $row['status'] . "</td>"; echo "</tr>"; } echo "</table>"; //connection close mysqli_close($con); ?>
在表1中,我使用 aNun_id 通过“GET”命令从另一个PHP文件中获取数据。 在表2中,我希望 bNun_id 在该表中显示其相关数据。如何从表一中将 bNun _id 数据调用到第二个表。请帮助我..
答案 0 :(得分:1)
这两个表是否在同一页面中? 如果是这样,您需要将bNum_id附加到相同的查询字符串以同时使用aNum_id和amp; bNum_id。
echo "<td><a href='?aNun_id=".$_GET["aNun_id"]."&bNun_id=".$row['b_number']."'>" . $row['b_number'] . "</a></td>";