Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用&&登录条件进行访问_Php - Fatal编程技术网

Php 如何使用&&登录条件进行访问

Php 如何使用&&登录条件进行访问,php,Php,您好,先生/女士!我是新手程序员。我想问一下如何在foreach语句中使用&&符号作为条件?我搜索了解决方案,但只能找到C的结果。如果我的英语语法不好,我很抱歉。另外,请原谅,如果你觉得这个问题太简单,因为我是一个新手 我的示例代码是: $accountval = array(); $accountidval = array(); $account = mysql_query("SELECT * FROM account where region = '$regionval' "); whi

您好,先生/女士!我是新手程序员。我想问一下如何在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>";
            }
提前感谢:

尝试阵列\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>';
}