【发布时间】:2013-11-20 02:38:42
【问题描述】:
是否可能复选框不会检查数据库中的行中是否存在值?
这是我的示例表
item_name | PR | checkbox |
ballpen | pr100 | □ |
pencil | pr111 | □ |
Paper | pr500 | □ |
Clip | | □ |
< Edit > < Add >
例如 item_name Clip 没有 PR 并且当我检查 Clip 行并单击 Edit 它不允许检查它或保留取消选中。如果数据库中有值,我想根据Edit 按钮进行验证。
这是我的短代码
app_list2.php
<?php
if (isset($_POST['submit'])) {
$mysqli = new mysqli("localhost", "root", "", "app");
//unset the session value
$_SESSION['content'] = '';
$drop = $_POST['drop_1'];
$tier_two = $_POST['tier_two'];
$where = "WHERE a.app_cn='$drop' AND a.app_plan_no='$tier_two'";
$result1 = $mysqli->query("
SELECT a.*, a.counter as sucks, b.counter, b.pr
FROM app a
LEFT OUTER JOIN purchase_request b
ON a.counter=b.counter
$where
GROUP BY a.counter ORDER BY a.item_name
");
?>
<?php
echo '<table id="tfhover" cellspacing="0" class="tablesorter" style="text-transform:uppercase;">
<thead>
<tr>
<th rowspan="2">PR</th>
<th rowspan="2" id="none"></th>
</tr>
</thead>';
echo '<tbody>';
$i = 1;
while ($row = $result1->fetch_assoc()) {
if ($row['app_cn'] != '') {
echo '<tr>
<td>' . $i++ . '</td>
<td>' . $row['item_name'] . '</td>
<td>' . $row['pr'] . '</td>
<td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="' . $row['sucks'] . '"></td>
</tr>';
}
}
echo "</tbody></table>";
$sPageContent = ob_get_clean();
$_SESSION['content'] = $sPageContent;
echo $_SESSION['content'];
} else {
if (isset($_SESSION['content'])) {
echo $_SESSION['content'];
}
}
?>
<a class="button" href="javascript:document.forms[0].submit();" onclick="f1.action='editpr.php'; return true;"><span><b>Edit Purchase Request</b></span></a>
<a class="button" href="javascript:document.forms[0].submit();" onclick="f1.action='addpr.php'; return true;"><span><b>Add to Purchase Request</b></span></a>
</form>
【问题讨论】:
标签: javascript php jquery checkbox mysqli