我想在php中寻求一些关于我的查询问题的帮助…我想做的是用相同的数字计数所有(atic),如果特定的(atic)等于7,我的插入查询将执行到那个(atic)。
问题是我的计数查询不会工作,因为我对所有的aic执行wanted....and查询,即使计数不是= 7。

当前代码:
<?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)");
}
}
?>发布于 2014-02-17 01:03:46
$query = 7表示将值7赋值给变量$query
为了进行比较,您必须使用双等号==
对于相同的数据类型,则为三重等号===。
发布于 2014-02-17 01:31:07
if($query = 7) 意味着您将$query赋值为7,并且它将始终为真并始终执行,您可以尝试这样做
if( $query == 7 )这意味着$query值是否等于7
https://stackoverflow.com/questions/21814321
复制相似问题