Php 在新页面上显示外键记录

Php 在新页面上显示外键记录,php,html,mysql,sql,Php,Html,Mysql,Sql,我有这张卡车的桌子 <div class="myform"> <form id="form" name="form" method="post" action=""> <table border="1"> <tr> <th>Plate Number</th> </tr> <?php do { ?>

我有这张卡车的桌子

<div class="myform">
    <form id="form" name="form" method="post" action="">
      <table border="1">
        <tr>
          <th>Plate Number</th>
        </tr>
        <?php do { ?>
          <tr>
            <td><?php echo strtoupper($row_Trucks['truck_plate_no']); ?></td>
          </tr>
        <?php } while ($row_Trucks = mysql_fetch_assoc($Trucks)); ?>
      </table>

    </form>
</div>
并且还连接到数据库中的一组其他表。当我单击表上的卡车车牌号并将我链接到另一个页面,该页面将显示与该卡车相关的所有记录时,如何显示与每个卡车相关的记录,卡车表是其他表上的外键。

尝试类似的操作。 如果
truck\u plate\u number
是唯一的,您可以将其与如下所示的链接一起传递。否则,获取记录的ID(主键),并用下面代码中的ID替换
$truck\u plate\u no

<div class="myform">
        <form id="form" name="form" method="post" action="">
        <table border="1">
        <tr>
        <th>Plate Number</th>
        </tr>
                <?php do {
        $truck_plate_no=$row_Trucks['truck_plate_no'];
        echo '<tr><td><a href=anotherpage.php?truck_plate_no='.$truck_plate_no.'>'.strtoupper($truck_plate_no).'</td></tr>';

               } while ($row_Trucks = mysql_fetch_assoc($Trucks));
              ?>
              </table>

车牌号
在anotherpage.php中

<?php  
$truck_plate_number=$_GET['truck_plate_no'];//get value from url

?>


然后使用此id查询表中的详细信息。

通过查询字符串在链接中传递id,并在链接到的页面上,使用该id值在DB中运行查询并显示信息。
<?php  
$truck_plate_number=$_GET['truck_plate_no'];//get value from url

?>