kelvin kelvin - 4 months ago 49
PHP Question

Displaying 2 records in a column using php

So I have a code

$showorder = "SELECT order_number FROM orders WHERE customer_number=522";
$orderesult = mysqli_query($con, $showorder);
$ord = mysqli_fetch_array($orderesult);

in my database customer number 522 has 2 order numbers, when i tried to show the result, it only shows 1.

Here's my other code

echo "<table>";
echo "<th>Order Number</th><th>Order date</th>";
echo "<tr><td>";
echo $ord["order_number"];
echo "</td><td>";
echo $ord["order_date"];
echo "</td></tr>";


You just need to use while() here for getting all records, something like:

while($ord = mysqli_fetch_array($orderesult)){
   //echo all value here

Also note that, if you want to print $ord["order_date"] than you must need to select column also in your query.

Otherwise, $ord will only contain order_number value.