这是我的billingHistory.php文件 &#39 ;;
include 'systemMenu.php';
echo '<h4>All Charges</h4>';
$user = unserialize($_SESSION['user']);
$query = "SELECT * FROM billingItems WHERE userID='".$user->userID. " ' GROUP BY deliveryTimestamp DESC";
$result = mysqli_query($db, $query);
while($row = mysqli_fetch_array($result)){
echo '<p>';
echo '<a href="billingHistory1.php?deliveryTimestamp=' .$row["deliveryTimestamp"]. '">'.
' Order Delivered on' . '</a>' .$row['deliveryTimestamp'] ;
}
echo '</div></body></html>';
$_SESSION['user'] = serialize($user);
include 'footer.html';
?>
这是我的billingHistory1.php
<?php
include 'preCode.php';
include 'header.php';
echo '<body><div class="standardLayout">';
include 'systemMenu.php';
echo '<h2>All Charges</h2>';
$user = unserialize($_SESSION['user']);
$query = "SELECT * FROM billingItems WHERE userID='" .$user->userID. "' AND DELIVERYTIMESTAMP='" .$_REQUEST["deliveryTimestamp"]. "' ORDER BY deliveryTimestamp DESC";
$result = mysqli_query($db, $query);
while($row = mysqli_fetch_array($result)){
echo '<p>';
echo '<p>'. $row['type'] . '<br>' .
'Cost: $' . $row['amount'] . '<br>' . '</p>' ;
}
echo '<h2>Order History</h2>';
$query1 = "SELECT * from Orders WHERE userID = '" . $user->userID . "' AND delivered = '1' GROUP BY ID DESC";
$result1 = mysqli_query($db, $query1);
while ($row1 = mysqli_fetch_array($result1)){
echo '<p>';
echo $row1["produce"] . ',' . $row1["meat"] . ',' . $row1["bakeryBread"] . ',' . $row1["frozen"] . ',' . $row1["dairy"] . ',
' . $row1["snacks"] . ',' . $row1["cannedFood"] . '</p>' ;
}
echo '</div></body></html>';
$_SESSION['user'] = serialize($user);
include 'footer.html';
?>
这是我的第一个输出:(订单已送达是超链接)
All Charges
Order Delivered on2015-05-16 14:48:17
Order Delivered on2015-05-16 14:46:21
这是我的第二个输出:(当客户点击订单已交付(超链接)时,它应显示所有费用,并且只显示与费用相关联的一个订单历史记录,而不是显示所有订单历史记录。
All Charges
Grocery Cost
Cost: $2.49
Shopping & Delivery
Cost: $0.00
Order History
1 Chilli,fish,bread,ice,milk, ,
2 Tomatoes,,,,, ,
答案 0 :(得分:2)
您需要添加这样的LIMIT:
SELECT * FROM billingItems WHERE userID='".$user->userID. " ' GROUP BY deliveryTimestamp DESC LIMIT 1
...或扩展您的WHERE子句以限制更多。