这段代码有什么不对......当我跑的时候显示这条消息......
中给出了警告:mysql_num_rows()期望参数1为resource,boolean
$startIndex = 1 ;
$finalIndex = 3;
$select_order = "SELECT orders.OrderID,orders.OrederDate,customer.FirstName,customer.LastName,orders.ShippingAddress,shopping_cart.GrandTotal,orders.Status FROM orders "
. "INNER JOIN customer ON orders.CustomerID = customer.CustomerID"
. "INNER JOIN shopping_cart ON shopping_cart.OrderID = orders.OrderID limit $startIndex,$finalIndex";
$result = mysql_query($select_order);
$jsonOrder = array();
if (mysql_num_rows($result) > 0) {
// output data of each row
while($row = mysql_fetch_assoc($result)) {
$jsonOrder[] = array('order ID' => $row["orders.OrderID"] ,'purchased Date' => $row["orders.OrederDate"],'customer Name' => $row["cutomer.FirstName"] ." ". $row["customer.LastName"], // we can use CONCAT(,)function for add two strings like 'customer name' => $row['CONCAT(FirstName,LastName)']
'shipping Address' => $row["orders.ShippingAddress"] ,'total price' => $row["shopping_cart.GrandTotal"],
'status' => $row["orders.Status"]);
}
$jsonstring = json_encode($jsonOrder);
echo $jsonstring;
} else {
echo "0 results";
}
答案 0 :(得分:1)
您需要在此处添加space
. " INNER JOIN shopping_cart ON shopping_cart.OrderID = orders.OrderID limit $startIndex,$finalIndex";
^^