dongxian0421 2013-12-07 02:26
浏览 28
已采纳

在新页面上显示外键记录

i have this table of trucks.

<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>

and this list of trucks is related to a delivery details table

tbl_delivery_details, tbl_po, tbl_waybill, tbl_fuel_details, tbl_driver...

and also connected to a bunch of other tables in the database. How can i display the records related to each of the trucks when i click the truck plate number on the table and link me to another page that will show me all the records related to that truck, the truck table is a foreign key on the other tables.

  • 写回答

1条回答 默认 最新

  • dongzhenbi8919 2013-12-07 04:07
    关注

    Try something like this. If truck_plate_number is unique,you can pass it along with the link as shown below.Otherwise,get the ID of record(primary key) and replace the $truck_plate_no with that ID in the below code.

    <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>
    

    In anotherpage.php

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

    Then query, details from the table using this id.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路