How to show all the maintainance history when user click on the registration number
i want to show all the vehicle maintenance history when user click on the registration number. but, when user click on the registration number, the page only show the latest data. for example, TAC 2123 have 5 maintenance record, but when user select the registration number, it only show the detail of the latest record. how can make it show all the TAC 2123 maintenance record?
here's the code for user select the registration number:
<table width="250" cellspacing="1" cellpadding="1" border="1" align="center">
<tr>
<td>No</td>
<td>Registration No</td>
</tr>
<?php
$count = 0;
$db = mysql_connect('localhost','root')
or die ("unable to connect");
mysql_select_db('fyp',$db) or die ("able to select");
$sql="SELE开发者_开发技巧CT * FROM vehicle_record WHERE faculty ='City Campus'";
$result = mysql_query($sql) or die ("Query failed!");
while($row = mysql_fetch_array($result)){
$count = $count + 1;
?>
<tr>
<td><?php echo $count; ?></td>
<td><a href="man_his_details.php?regis=<?php echo $row['regno']; ?>"><?php echo $row['regno']; ?></a></td>
</tr>
<?php
}
mysql_close($db);
?>
</table>
and here's the code to list all the maintenance record based on the selected registration number:
<table width="990" cellspacing="1" cellpadding="1" border="1" align="center">
<tr>
<td>No</td>
<td>Maintenance Date</td>
<td>Maintenance Detail</td>
<td>Last Mileage</td>
<td>Next Change (Mileage)</td>
<td>Warranty</td>
<td>Cost</td>
<td>Driver Name</td>
</tr>
<?php
$count = 0;
if(isset($_GET['regis']))
$regno = $_GET['regis'];
elseif(isset($_POST['regis']))
$regno = $_POST['regis'];
else
$regno = "";
$db = mysql_connect('localhost','root')
or die ("unable to connect");
mysql_select_db('fyp',$db) or die ("able to select");
$sql_select = "SELECT * FROM maintenance WHERE regno ='".$regno."' ";
//. " WHERE `regno`='".($regno)."'";
//die($sql_select);
$result = mysql_query($sql_select) or die ("Query failed!");
$row = mysql_fetch_array($result);
extract($row);
//die($sql_select);
$count = $count + 1;
?>
<tr>
<td><?php echo $count; ?></td>
<td><?php echo $row['mdate']; ?></td>
<td><?php echo $row['man_detail']; ?></td>
<td><?php echo $row['last_mile']; ?></td>
<td><?php echo $row['next_mile']; ?></td>
<td><?php echo $row['warranty']; ?></td>
<td><?php echo $row['cost']; ?></td>
<td><?php echo $row['driver_name']; ?></td>
</tr>
<?php
//}
mysql_close($db);
?>
plzzz help me!!!
You need to put a while loop around the logic that fetches and prints the records:
while ($row = mysql_fetch_array($result)) {
$count = $count + 1;
?>
<tr>
<td><?php echo $count; ?></td>
<td><?php echo $row['mdate']; ?></td>
<td><?php echo $row['man_detail']; ?></td>
<td><?php echo $row['last_mile']; ?></td>
<td><?php echo $row['next_mile']; ?></td>
<td><?php echo $row['warranty']; ?></td>
<td><?php echo $row['cost']; ?></td>
<td><?php echo $row['driver_name']; ?></td>
</tr>
<?php
} // end while
mysql_close($db);
?>
精彩评论