Good morning, I need some help and would really appreciate it. I have a table that looks like the following:
But I want it to look like this so its easier for the user to read:
How do i change it to look like that? Here’s the current code:
<?php
$sql = "SELECT
companyname,
ordernumber,
equipment,
theserial,
type,
theaddress
FROM table";
$result = mysqli_query($con, $sql);
?>
<table id="moreinfotable" name="moreinfotable" class="table table-bordered" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>OrderNumber</th>
<th>Equipment</th>
<th>Serial</th>
<th>Type</th>
<th>Address</th>
</tr>
</thead>
<?php
while($row = mysqli_fetch_array($result)) {
$companyname = $row['companyname'];
$ordernumber = $row['ordernumber'];
$equipment = $row['equipment'];
$theserial = $row['theserial'];
$type = $row['type'];
$theaddress = $row['theaddress'];
echo '<tr>';
echo '<td>' . $companyname . '</td>';
echo '<td>' . $ordernumber . '</td>';
echo '<td>' . $equipment . '</td>';
echo '<td>' . $theserial . '</td>';
echo '<td>' . $type . '</td>';
echo '<td>' . $theaddress . '</td>';
echo'</tr>';
}
?>
</table>
2
Answers
For a fixed list of types (here, new delivery and pickup), you can pivot your dataset directly in SQL with conditional aggregation:
I am not sure but did you try ordering your query ?
For example:
SELECT * FROM exam ORDER BY exam_date;
Which means select all from exam and order it by exam_date.