如何用&&和登录条件PHP

时间:2015-08-26 05:51:54

标签: php

美好的一天先生/女士!我是新手程序员。我想问一下如何在&&语句中使用foreach符号作为条件?我搜索了解决方案,但只能找到C#的结果。如果我的英语语法差,我很抱歉。如果你觉得这个问题太容易了,请原谅我。

我的示例代码是:

$accountval = array();
$accountidval = array();

$account = mysql_query("SELECT * FROM account where region = '$regionval' ");

while($rowaccount = mysql_fetch_array($account))
{
$accountval[] = $rowaccount['accountname'];
$accountidval[] = $rowaccount['id'];
}

foreach($accountval as $key => $accountname && $accountidval as $key1 =>$accountid)
            {
            echo "<option value='{$accountid}'>".$accountname."</option>";
            }

提前致谢:)

3 个答案:

答案 0 :(得分:2)

foreach(array_merge($accountval=>$accountname,$accountidval=>$accountid)) as $key {echo "";}

答案 1 :(得分:2)

尝试array_combine()

foreach (array_combine($accountval, $accountidval) as $accountname => $accountid) {
    echo '<option value="' . $accountid . '">' . $accountname . '</option>';
}

答案 2 :(得分:0)

<n>Query: Create EVENT checkBlack2 on Schedule every 5 second DO Delete from BlackList where id=13 0 row(s) affected语句中不能包含条件。 See the official documentation of here。您需要使用foreach循环,也可以根据您的具体需要使用for语句。