【发布时间】:2016-03-31 08:05:04
【问题描述】:
我已经被这个问题困扰了一段时间了。如果未填写 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();
【问题讨论】:
-
你为什么要做不必要的 parent().children() ???只需这样做:
$('table').find("td:nth-child(2):empty").parent().hide(); -
是的 svar=answer,抱歉我之前没有澄清
-
那么只更新查询以不选择不需要的记录呢?
标签: php jquery mysql html-table