PHP如何使用rowspan单元格,并使用查询使其文本垂直

Attached you a shot, I want to merge cells in Kitchen Time column, and make time text to be vertical, I tried a lot but all I did just to hide cells if kitchen time was the same in below cells, and hide border, but it's not what I'm looking for! Here is the screenshot:

merge cells

Code:

<?php
include_once("config.php");
if ($conn -> connect_error > 0) {
   die('Unable to connect to database [' . $conn -> connect_error . ']');}?>

<table id = "table" class = "table table-bordered">
    <thead class = "alert-info">
        <tr>
            <th>Kitchen Time</th>
            <th>Order#</th>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Address</th>
            <th>Driver#</th>
            <th>Delivery Time</th>
            <th># of People</th>
            <th>Miles</th>     </tr>
    </thead><tbody>
<?php
$dtpickerdate = isset($_POST['dtpickerdate']) ? $_POST['dtpickerdate'] : NULL;
$q_customer = $conn->query
("SELECT * from orders inner JOIN customer_order on customer_order.order_no =orders.order_no AND customer_order.order_date like'$dtpickerdate' AND 
orders.date like'$dtpickerdate' inner join driver_order on driver_order.order_no=orders.order_no and driver_order.order_date like'$dtpickerdate'
LEFT JOIN customer on customer.phone=customer_order.phone order by k_time,time desc" ) or die(mysqli_error());

$k_time = '';


while($f_customer = $q_customer->fetch_array()){?>
  <tr>
    <?php   
{
if($k_time == '' || $k_time != $f_customer['k_time']){
      $k_time = $f_customer['k_time'];

echo '<td align="center" > <span style="font-weight:bold;">' .$f_customer['k_time']. '</td>';

    } else{
      echo "<td style='border: none;'>&nbsp;</td>";
    }?>
<td  align='center'  span style="font-weight:bold;"><a data-controls-modal="action" data-backdrop="static" data-keyboard="false" href="options.php?id=<?php echo $f_customer['order_no']?>&date=<?php echo $dtpickerdate?>" data-toggle = "modal" data-target = "#action"><?php echo $f_customer['order_no']?></a></td>

<?php
echo    "<td>" .$f_customer['first_name']."</td>";  
echo "<td>". $f_customer['last_name']."</td>";
echo "<td>". $f_customer['address']."</td>";
echo "<td>". $f_customer['driver_no']."</td>";
echo "<td>". $f_customer['d_time']."</td>";
echo "<td>". $f_customer['no_ofppl']."</td>";
echo "<td>". $f_customer['km']."</td>";       

} }

?>
</tbody>
</table>

on go we cannot find the rowspan. for that

  1. find the count of rows to merge using query itself.
  2. loop the result and create a multi dimensional array and using array print the table
  3. create a string of html. keep a string for rowspan. replace that string with actual value at the end

here is the sample with 3

<?php
include_once("config.php");
if ($conn -> connect_error > 0) {
    die('Unable to connect to database [' . $conn -> connect_error . ']');
}
 $tbody = '<table id = "table" class = "table table-bordered">
            <thead class = "alert-info">
                <tr>
                    <th>Kitchen Time</th>
                    <th>Order#</th>
                    <th>First Name</th>
                    <th>Last Name</th>
                    <th>Address</th>
                    <th>Driver#</th>
                    <th>Delivery Time</th>
                    <th># of People</th>
                    <th>Miles</th>     </tr>
            </thead>
            <tbody>';
$dtpickerdate = isset($_POST['dtpickerdate']) ? $_POST['dtpickerdate'] : NULL;
$q_customer = $conn->query
("SELECT * from orders inner JOIN customer_order on customer_order.order_no =orders.order_no AND customer_order.order_date like'$dtpickerdate' AND
orders.date like'$dtpickerdate' inner join driver_order on driver_order.order_no=orders.order_no and driver_order.order_date like'$dtpickerdate'
LEFT JOIN customer on customer.phone=customer_order.phone order by k_time,time desc" ) or die(mysqli_error());

$k_time     = '';
$kTimeArry  = array();

while($f_customer = $q_customer->fetch_array()){
    $tbody .= "<tr>";
    if ($k_time == '' || $k_time != $f_customer['k_time']) {//assign a hardcoded string for indicating rowspan. will replace acxtual value at the end
        $k_time = $f_customer['k_time'];
        $tbody .= '<td align="center" rowspan="###rowspan_'.$f_customer['k_time'].'"> <span style="font-weight:bold;">' .$f_customer['k_time']. '</td>';
    }
    $kTimeArry[$f_customer['k_time']] = $kTimeArry[$f_customer['k_time']]+1;//array to find rowspan
    $tbody .=   "<td  align='center'  span style=\"font-weight:bold;\">".
            "<a data-controls-modal=\"action\" data-backdrop=\"static\" data-keyboard=\"false\"".
            "href=\"options.php?id={$f_customer['order_no']}&date=$dtpickerdate\" ".
            "data-toggle = \"modal\" data-target = \"#action\">{$f_customer['order_no']}</a></td>";

$tbody .= "<td>" .$f_customer['first_name']."</td>";
$tbody .= "<td>". $f_customer['last_name']."</td>";
$tbody .= "<td>". $f_customer['address']."</td>";
$tbody .= "<td>". $f_customer['driver_no']."</td>";
$tbody .= "<td>". $f_customer['d_time']."</td>";
$tbody .= "<td>". $f_customer['no_ofppl']."</td>";
$tbody .= "<td>". $f_customer['km']."</td>";
$tbody .= "</tr>";
}
$tbody .= "</tbody>
        </table>";
foreach ($kTimeArry AS $ktime => $ktimeCount) {//'###rowspan_'.$ktime replace string with corresponding rowspan
    $tbody = str_replace('###rowspan_'.$ktime, $ktimeCount, $tbody);
}
//print table
echo $tbody ;

Note: didn't executed the shared code. So check the logic and apply according to your result.