what the wrong in this code .... when i run show this message ...
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean
given in
$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";
}
Answer:
You need to add space
here
. " INNER JOIN shopping_cart ON shopping_cart.OrderID = orders.OrderID limit $startIndex,$finalIndex";
^^
No comments:
Post a Comment