<input type="text" id="A1" name="A1">
在上面的框中,从mysql(框中的fetch)放置0或1。现在我想要那个:
值框= 0&gt;&gt;复选框未选中
值框= 1&gt;&gt;选中复选框
如何使用复选框(type =“checkbox”)而不是text(type =“text”)?
<input type="checkbox" id="A1" name="A1">
答案 0 :(得分:3)
你可以这样检查:
<?php
$box_val = 1; // rertive this value from database
?>
<input type="checkbox" id="A1" name="A1" <?=($box_val == 1) ? "checked" : "" ?>>
答案 1 :(得分:1)
你可以这样做:
<input id="A1" name="A1" checked="0" type="checkbox">
<script>
$('#A1').prop("checked",$mySqlValue);
</script>
如果$mySqlValue==1
该框将被选中,并且$mySqlValue==0
将不会被选中。
答案 2 :(得分:0)
您可以使用js
#include <opencv2\opencv.hpp>
#include <algorithm>
using namespace std;
using namespace cv;
void selectColumns(const Mat& src, Mat& dst, const vector<int>& columns)
{
assert(!columns.empty());
// Be sure that the column indices are valid.
// They may not be sorted.
auto limits = minmax_element(columns.begin(), columns.end());
assert(*limits.first >= 0);
assert(*limits.second < src.cols);
int cols = int(columns.size());
dst.create(src.rows, cols, src.type());
for (int i = 0; i < cols; ++i) {
src.col(columns[i]).copyTo(dst.col(i));
}
}
int main()
{
Mat3f nn(3, 5);
randu(nn, Scalar(0), Scalar(255,255,255));
Mat mm;
selectColumns(nn, mm, { 0,2 });
return 0;
}
答案 3 :(得分:0)
你好Reza Hatami,
请尝试以下代码,
存储数据中的$my_checkbox
变量从mysql数据库中恢复。
<?php
$my_checkbox = 1;
?>
<input type="checkbox" id="Notification" name="Notification" <?php echo if($mycheckbox == 1) ? 'checked=""': ""; ?> />
也使用,但在这个问题是一些浏览器或PHP版本不支持所以我的建议使用上面的代码。
<?php
$my_checkbox = 1;
?>
<input type="checkbox" id="Notification" name="Notification" <?=($my_checkbox == 1) ? "checked" : "" ?> />
我希望我的回答很有帮助。如果有任何疑问请评论。
答案 4 :(得分:0)
<input type="checkbox" id="A1" name="A1" <?php if($value==1) echo 'checked="checked"'; ?> >
$value
来自数据库