我開發了一個頁面,可以顯示錶格中的所有卡車車牌號碼,當您點擊車牌時,每次他們進入此頁面並顯示與我的問題顯示的車牌號碼相關的數據卡車的名稱,它只顯示不同卡車的每一頁上的第一個卡車車牌號,我點擊但顯示的數據正常工作我只是無法顯示正在顯示的數據的卡車車牌號碼顯示名稱而不是編號
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