我开发了一个页面,可以显示表格中的所有卡车车牌号码,当您点击车牌时,每次他们进入此页面并显示与我的问题显示的车牌号码相关的数据卡车的名称,它只显示不同卡车的每一页上的第一个卡车车牌号,我点击但显示的数据正常工作我只是无法显示正在显示的数据的卡车车牌号码显示名称而不是编号
I我通过这里显示板号<?php echo $row['truck_plate_no'];?>
但它只显示第一个板号这是我的代码:
<?php require_once('Connections/connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_connect, $connect);
$query_join = "SELECT * FROM tbl_delivery_details, tbl_truck WHERE tbl_truck.id_truck=tbl_delivery_details.tbl_truck_id_truck ORDER BY tbl_delivery_details.id_delivery_details";
$join = mysql_query($query_join, $connect) or die(mysql_error());
$row_join = mysql_fetch_assoc($join);
$totalRows_join = mysql_num_rows($join);
$id_truck = mysql_real_escape_string($_GET['id_truck']);
$sql_PK = "SELECT * FROM tbl_delivery_details WHERE tbl_truck_id_truck = {$id_truck}";
$PK = mysql_query($sql_PK, $connect);
if (mysql_error()) {
die (mysql_error());
}
$row_PK = mysql_fetch_assoc($PK);
$truck_id = $row_PK['tbl_truck_id_truck'];
$truck_id = mysql_real_escape_string($truck_id);
$sql = "SELECT tbl_truck.truck_plate_no,
tbl_delivery_details.delivery_details_route,
tbl_delivery_details.delivery_details_destination,
tbl_delivery_details.delivery_details_van_no,
tbl_delivery_details.delivery_details_waybill_no,
tbl_delivery_details.delivery_details_charge_invoice,
tbl_delivery_details.delivery_details_revenue,
tbl_delivery_details.delivery_details_strip_stuff,
tbl_delivery_details.delivery_details_date
FROM tbl_truck, tbl_delivery_details
WHERE tbl_truck.id_truck = tbl_delivery_details.tbl_truck_id_truck
ORDER BY tbl_truck.truck_plate_no";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($res);
$sum = 0;
$sum1 = 0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/x html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Truck Delivery</title>
<link rel="stylesheet" type="text/css" href="qcc.css"/>
<link rel="shortcut icon" href="images/icon.ico">
</head>
<body>
<div id="logo">
<a href="home.php" title="QCC Corporation"><img src="images/logo_comp.jpg" width="245" height="105" alt="QCC Corporation"></a>
</div>
<div id="nav">
<a href="form.php">Add-Transactions</a>
<a href="truck.php">Truck</a>
<a href="driver.php">Driver</a>
<a href="customer.php">Customer</a>
<a href="fuelsource.php">Fill-up-source</a>
<a href="report.php">Reports</a>
</div>
<div id="border">
<hr />
</div>
<div id="content"><table border="1" table align="center">
<th>Date</th>
<th>Route</th>
<th>Destination</th>
<th>Van No.</th>
<th>Waybill No.</th>
<th>Charge Invoice</th>
<th>Revenue</th>
<th>Strip/Stuff</th>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_PK['delivery_details_date']; ?></td>
<td><?php echo $row_PK['delivery_details_route']; ?></td>
<td><?php echo $row_PK['delivery_details_destination']; ?></td>
<td><?php echo $row_PK['delivery_details_van_no']; ?></td>
<td><?php echo $row_PK['delivery_details_waybill_no']; ?></td>
<td><?php echo $row_PK['delivery_details_charge_invoice']; ?></td>
<td><?php echo $row_PK['delivery_details_revenue']; ?></td>
<td><?php echo $row_PK['delivery_details_strip_stuff']; ?></td>
</tr>
<?php $revenue = $row_PK['delivery_details_revenue'];
$sum += $revenue;
?>
<?php $strip = $row_PK['delivery_details_strip_stuff'];
$sum1 += $strip;
?>
<?php } while ($row_PK = mysql_fetch_assoc($PK)); ?>
</table>
</div>
<div id="revenue">
Total Revenue: <?php echo $sum;?>
</div>
<div id="strip">
Total Stripping/Stuffing: <?php echo $sum1;?>
</div>
<div id="head">
<?php echo $row['truck_plate_no'];?>
</div>
</body>
<div id="footer">
<br/><br/>Copyright © 2013 WFJCC. All rights reserved.
</div>
</html>
<?php
mysql_free_result($join);
?>
有多少行应该有? – 2013-02-23 07:55:03
我不希望它被放入表格中,我只是想显示哪些卡车车牌号码的数据属于,并把它们放在页面的顶部 – 2013-02-23 07:58:24
[**请不要使用'mysql_ *'功能在新代码**](http://bit.ly/phpmsql)。他们不再被维护[并且被正式弃用](http://j.mp/XqV7Lp)。看到[**红框**](http://j.mp/Te9zIL)?学习[*准备的语句*](http://j.mp/T9hLWi),并使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [这篇文章](http://j.mp/QEx8IB)将帮助你决定哪个。如果你选择PDO,[这里是一个很好的教程](http://j.mp/PoWehJ)。 – 2013-02-23 08:09:06