给你一个镜头,我想合并Kitchen Time栏中的单元格,并将时间文本设置为垂直,我尝试了很多,但我只是隐藏单元格,如果下面的单元格中的厨房时间相同,则隐藏边界,但它不是我想要的!这是截图:
代码:
<?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;'> </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>
答案 0 :(得分:0)
开始我们找不到rowspan。那个
这是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 ;
注意:没有执行共享代码。因此,请检查逻辑并根据您的结果进行申请。