问题描述
我必须遗漏一些相当明显的东西。我有以下
代码片段,当它应该只回显一次(数组中只有一个元素)时,它回显'我的结果两次。我在俯瞰什么?
********************************
$ OpenQ = mysql_query(" SELECT column FROM table WHERE q_uid =
$ _SESSION [userid] AND status = 1",$ db); // DB上的SQL查询返回1
结果
$ Qresult = mysql_fetch_array($ OpenQ); //获取数组
if($ _GET [''OQ'']){//如果收到get变量
foreach($ Qresult作为$ Q){
echo"< br>" 。 $ Q;
}
}
***************** ****************
TY。
I must be missing something rather obvious. I have the following
snippet of code that echo''s my result twice when it should be echoing
just once (only one element in the array). What am I overlooking?
********************************
$OpenQ = mysql_query("SELECT column FROM table WHERE q_uid =
$_SESSION[userid] AND status = 1",$db); // SQL query on DB returns 1
result
$Qresult = mysql_fetch_array($OpenQ); // Fetch the array
if ($_GET[''OQ'']) { // If the get variable is recieved
foreach ($Qresult as $Q) {
echo "<br>" . $Q;
}
}
*********************************
TY.
这篇关于Foreach显示数据两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!