我想寻求有关PHP查询问题的帮助...我想做的是计算所有(atic)具有相同的数字,如果特定(atic)等于7,则我的插入查询将对此执行(atic )。

问题是我的计数查询无法按我想要的那样工作....即使所有的aic都不是7,也要对所有aic执行我的插入查询。



当前代码:

<?php
mysql_connect("localhost","root","") or die("cant connect!");
mysql_select_db("klayton") or die("cant find database!");
$total = NULL;
$count = "SELECT count(t.atic) as '$total', t2.name FROM app_interview as t, tb_applicants as t2 WHERE t.atic = t2.aic GROUP BY t.atic";
$query = mysql_query($count) or die (mysql_error());
while($rows =mysql_fetch_array($query)){
if($query = 7){
    mysql_query("INSERT INTO afnup_worksheet (faic,fnl_name,interview,fregion,ftown,funiq_id,fposition,fsalary_grade,fsalary,dateinputed) SELECT DISTINCT atic, atname,(SELECT sum(inttotal) FROM app_interview t2 WHERE t2.atic = t.atic)/7, region, town, uniq_id, position, salary_grade, salary, CURRENT_TIMESTAMP FROM app_interview t GROUP BY atname HAVING COUNT(DISTINCT atic)");
}
}
?>

最佳答案

$query = 7表示您正在将值7分配给变量$query

为了进行比较,您必须使用双等号==

或相同数据类型的三等号===

10-01 23:05