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