Im currently trying to make a table with information from two mysql tables "order" and "order\_items" as they both share order id

order

![http://gyazo.com/b5761696c5650d0f24d883fd914f3564.png](https://i.stack.imgur.com/liHZ0.png)

order\_items

![enter image description here](https://i.stack.imgur.com/1d5Rf.png)

I want to display a table like this with the product names in the same row which would take a loop maybe

![enter image description here](https://i.stack.imgur.com/0F2LT.png)

i want do this with an inner join as it more marks for what im doing

This is what i have at the moment but doesnt work at the moment

```
$query = "SELECT order.date_bought, order.total_price, order_items.product_name FROM order INNER JOIN order_items ON order.order_id = order_items.order_id WHERE order.student_id = $id ORDER BY order_id DESC";

$result = mysql_query($query);

$num = mysql_num_rows($result);

$i=0;

while($i < $num){
$date_bought = mysql_result($result,$i,"date_bought");

echo $date_bought;

}

```

error: mysql\_num\_rows() expects parameter 1 to be resource, boolean given

but im pretty sure its because of the query