gpt4 book ai didi

php - 如果该行中的某个单元格为空,如何隐藏整行?

转载 作者:行者123 更新时间:2023-11-29 05:14:53 26 4
gpt4 key购买 nike

我已经坚持了一段时间了。如果第二列 (svar) 单元格在未填充 svar 下的单元格的所有行上为空,我如何隐藏一行?

到目前为止,这是我的代码:

PHP

$localhost = "localhost";
$username = "root";
$password = "";

$connect = mysqli_connect($localhost, $username, $password)or
die("Kunde inte koppla");

mysqli_select_db($connect, 'wildfire');

$result = mysqli_query($connect,"SELECT * FROM question");

echo "<table border='1'>
<tr>
<th>Fråga</th>
<th>Svar</th>
<th>Poäng</th>
<th>Redigera</th>
<th>Radera</th>
<th>AID</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['qid'] . "</td>";
echo "<td>" . $row['answer'] . "</td>";
echo "<td>" . $row['Point'] . "</td>";
echo "<td><a href=\"editdilemman.php?aid=".$row['aid']."\">Redigera</a></td>";
echo "<td><a href=\"radera.php?id=".$row['aid']."\">Ta bort</a></td>";
echo "<td>" . $row['aid'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysqli_close($connect);

JQuery

 var t = $('table').parent().children().find("td:nth-child(2):empty").parent().hide();

最佳答案

我会更新查询,以便您只返回要显示的记录。所以改变:

$result = mysqli_query($connect,"SELECT * FROM question");

$result = mysqli_query($connect,"SELECT * FROM question where answer <> '' && answer IS NOT NULL");

关于php - 如果该行中的某个单元格为空,如何隐藏整行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34460215/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com