Php 函数检查MySQL表中的字段是否等于1
对于下面的MySQL表,哪个PHP函数会简单地测试'subcheck'是否等于1 提前感谢, 约翰Php 函数检查MySQL表中的字段是否等于1,php,mysql,Php,Mysql,对于下面的MySQL表,哪个PHP函数会简单地测试'subcheck'是否等于1 提前感谢, 约翰 您没有提供太多需要的信息,例如表名、检查条件,所以我只提供一个简单的查询供您使用 $query = mysql_query('SELECT subcheck FROM your_table WHERE subcheck = "1"'); if ($query) { //your subcheck is 1 } else { //your subcheck is not 1 / nothing w
您没有提供太多需要的信息,例如表名、检查条件,所以我只提供一个简单的查询供您使用
$query = mysql_query('SELECT subcheck FROM your_table WHERE subcheck = "1"');
if ($query)
{
//your subcheck is 1
}
else
{
//your subcheck is not 1 / nothing was found
}
如果您只需要选择具有特定submissionid的项目,最好将其更改为以下内容:
$submissionid = 809;
$query = mysql_query('SELECT subcheck
FROM your_table
WHERE submissionid = "' . $submissionid . '"');
if ($row = mysql_fetch_row($query))
{
if ($row[0] == 1) { } //your subcheck is one
else { } //your subcheck is not one
}
else { } //no matching records found
如果$submissionid将基于不安全的源(如用户输入),请记住转义$submissionid
$submissionid = 809;
$query = mysql_query('SELECT subcheck
FROM your_table
WHERE submissionid = "' . $submissionid . '"');
if ($row = mysql_fetch_row($query))
{
if ($row[0] == 1) { } //your subcheck is one
else { } //your subcheck is not one
}
else { } //no matching records found