Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 函数检查MySQL表中的字段是否等于1_Php_Mysql - Fatal编程技术网

Php 函数检查MySQL表中的字段是否等于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

对于下面的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 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