gpt4 book ai didi

php - 如何在用户点击注册号时显示所有维护历史

转载 作者:行者123 更新时间:2023-11-29 01:02:15 27 4
gpt4 key购买 nike

我想在用户点击注册号时显示所有车辆维修历史记录。但是,当用户点击注册号时,页面只显示最新的数据。例如,TAC 2123有5条维修记录,但当用户选择注册号时,它只显示最新记录的详细信息。如何让它显示所有TAC 2123维修记录?

这是用户选择注册号的代码:

<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="SELECT * 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);
?>

请帮帮我!!!

最佳答案

您需要围绕获取和打印记录的逻辑放置一个 while 循环:

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);
?>

关于php - 如何在用户点击注册号时显示所有维护历史,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2331488/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com