This question already has an answer here:
I'm developing a laundry service system, using php. I have 2 table, table customer and table ticket (with customer_id as the foreign key here).
so i'm trying to display a list of ticket after the user logged in, consists of data from table customer and table ticket.
i'm trying to join 2 table with customer_id as the link join.. for the logged in username(using $session to store username for logged in customer). here is my code:
$customerusername = $_SESSION['customerusername'];
$result = mysqli_query($conn,"SELECT * from TICKET INNER JOIN CUSTOMER ON TICKET.CUSTOMER_ID=CUSTOMER.CUSTOMER_ID
WHERE CUSTOMER_ID=(SELECT CUSTOMER_ID from CUSTOMER WHERE CUSTOMER_USER='$customerusername')");
however i got this error Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in this first line below:
while($row = mysqli_fetch_array($result)){ //Creates a loop to loop through results
$found_row = true;
echo " <tr>
<td>".$row['TICKET_ID']."</td>
<td>".$row['TICKET_PICKUP']."</td>
<td>".$row['TICKET_PTIME']."</td>
<td>".$row['TICKET_DELIVERY']."</td>
<td>".$row['TICKET_DTIME']."</td>
<td>".$row['TICKET_STATUS']."</td>
<td>RM ".$row['TICKET_PRICE']."</td>
<td>".$row['PAYMENT_STATUS']."</td>
</tr>";
}
if ($found_row == false) {
echo "No Ticket Submitted";
}
what went wrong?
</div>