php - Warning: mysql_num_rows() -
this question has answer here:
what wrong in code .... when run show message ...
warning: mysql_num_rows() expects parameter 1 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 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"], // can use concat(,)function add 2 strings '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"; }
you need add space
here
. " inner join shopping_cart on shopping_cart.orderid = orders.orderid limit $startindex,$finalindex"; ^^
Comments
Post a Comment