mysql_select_db("zaiping", $con);
$result = array();
$rs = mysql_query("select count(*) as count from dept where deptName like $deptName");
$row = mysql_fetch_array($rs);
ChromePhp::log($row);
$result["total"] = $row[0];
sql command line executionselect count(*) as count from dept where deptName like $deptName
is no problem. It is also no problem if the number of records >=2. The problem is that when there is 1 When matching data, $result["total"]=0, why is this, why is it not 1? Thanks
$rs = mysql_query("select count(*) as count from dept where deptName like '%".$deptName."%'");
SQL like 请加百分号
When this kind of problem occurs, I usually solve it like this:
Based on the output, make corresponding judgments to see where the problem lies.