已关闭此问题为not reproducible or was caused by typos。它目前不接受回答。
此问题是由打印错误或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这一个是解决的方式不太可能帮助未来的读者。
4天前关闭。
Improve this question
我遇到的问题是我的表格标题位于表格的每个单元格的顶部。
这是一个php文件,它被用来获取数据。
<?php
include 'connect.php';
include_once 'main.php';
if(isset($_POST['submit1'])){
$s_zone = $_POST['s_zone'];
$option = $_POST['select_but'];
if($option === 'Fedex'){
$countrysearch= ['country'];
$zonesearch= ['zone'];
$weightsearch= ['weight'];
$pricesearch= ['price'];
$find_zone = "SELECT * FROM fedex WHERE zone = '$s_zone'";
$run_zone = mysqli_query($conn, $find_zone);
}elseif($option === 'DHL'){
$countrysearch= ['country'];
$zonesearch= ['zone'];
$weightsearch= ['weight'];
$pricesearch= ['price'];
$find_zone = "SELECT * FROM dhl WHERE zone = '$s_zone'";
$run_zone = mysqli_query($conn, $find_zone);
}
}
?>
这是我的表格布局的HTML代码。
<!-- sesarch for calculator -->
<div class="calculation">
<h1>Calculator</h1>
<form action="" method="POST">
<div>
<label for= "zone"> </label>
<input type= "text" class= "input" name="s_zone" placeholder="search zone" required>
<input type= "text" class= "input" name = "stuffweight" placeholder= "weight" required>
<select name="select_but" class="dropdown">
<option>-Select-</option>
<option name="src_fedex">Fedex</option>
<option name="src_dhl">DHL</option>
</select>
<input type= "submit" class= "submit" name="submit1" value="Submit" >
</div>
<?php
if(isset($_POST['submit1'])){
while($row = mysqli_fetch_array($run_zone)){
?>
<table class="t_calcu">
<div>
<tr>
<th>Country</th>
<th>Zone</th>
<th>Weight</th>
<th>Price</th>
</tr>
</div>
<tr>
<td><?php echo $row ['country'] ?></td>
<td><?php echo $row ['zone'] ?></td>
<td><?php echo $row ['weight'] ?></td>
<td><?php echo $row ['price'] ?></td>
</tr>
</table>
<?php
}
}
?>
我尝试使用相同的代码布局与其他表,我有。然而,对于这个表,它从我的数据库中“获取”数据。但不幸的是,在使用相同的代码布局后,它仍然不起作用。
<!-- table to show the list of prices and zones that is being inputed -->
<div class="fedex_table">
<h1>FEDEX List</h1>
<table class="ft">
<div>
<tr>
<th>Country</th>
<th>Zone</th>
<th>Weight</th>
<th>Price</th>
</tr>
</div>
<tr>
<?php
while($row = $result->fetch_assoc())
{
?>
<td><?php echo $row ['country']?></td>
<td><?php echo $row ['zone']?></td>
<td><?php echo $row ['weight']?></td>
<td><?php echo $row ['price']?></td>
<td><a href="delete.php ?id=<?php echo $row ["id"];?>">Delete</a></td>
</tr>
<?php
}
?>
</table>
</div>
<div class="dhl_table">
<h1>DHL List</h1>
<table class="dt">
<div>
<tr>
<th>Country</th>
<th>Zone</th>
<th>Weight</th>
<th>Price</th>
</tr>
</div>
<tr>
<?php
while($row = $resultd->fetch_assoc())
{
?>
<td><?php echo $row ['country']?></td>
<td><?php echo $row ['zone']?></td>
<td><?php echo $row ['weight']?></td>
<td><?php echo $row ['price']?></td>
<td><a href="delete.php ?id=<?php echo $row ["id"];?>">Delete</a></td>
</tr>
<?php
}
?>
</table>
</div>
我所期望的是能够有一个TH“表头”,它停留在表的顶部。
1条答案
按热度按时间sqserrrh1#
你的HTML应该看起来更像这样:
在表中使用
thead
或tbody
等并不是强制性的,但它确实有助于描述意图是什么。因此,如上所述,在该位置无效的div
元素可以替换为thead
,并且新行和内容的创建都应该在各个循环中完成。