Php 如何使用&&登录条件进行访问
您好,先生/女士!我是新手程序员。我想问一下如何在foreach语句中使用&&符号作为条件?我搜索了解决方案,但只能找到C的结果。如果我的英语语法不好,我很抱歉。另外,请原谅,如果你觉得这个问题太简单,因为我是一个新手 我的示例代码是:Php 如何使用&&登录条件进行访问,php,Php,您好,先生/女士!我是新手程序员。我想问一下如何在foreach语句中使用&&符号作为条件?我搜索了解决方案,但只能找到C的结果。如果我的英语语法不好,我很抱歉。另外,请原谅,如果你觉得这个问题太简单,因为我是一个新手 我的示例代码是: $accountval = array(); $accountidval = array(); $account = mysql_query("SELECT * FROM account where region = '$regionval' "); whi
$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>";
}
提前感谢:尝试阵列\u组合
foreach(array_merge($accountval=>$accountname,$accountidval=>$accountid)) as $key {echo "";}
foreach语句中不能有条件。您将需要利用for循环,可能还有if语句,具体取决于您的具体需要
foreach (array_combine($accountval, $accountidval) as $accountname => $accountid) {
echo '<option value="' . $accountid . '">' . $accountname . '</option>';
}