检索它们例如,我有使用数组来存储信息和用PHP
<a href="FashionDetails.php?menu_id=1"></a>
<a href="FashionDetails.php?menu_id=2"></a>
<a href="FashionDetails.php?menu_id=3"></a>
<a href="FashionDetails.php?menu_id=4"></a>
和进程页: '$ fashion_id = $ _GET [ 'menu_id'];
if ($menu_id == "1") {
$id = "1";
$menu_name ="Business Fashion";
$img_file ="images/mushroomsoup.jpg";
$description ="mushroom soup";
$color ="red";
}
elseif($menu_id =="2") {
$id ="2";
$menu_name ="minestrone soup";
$img_file ="images/mine.jpg";
$description ="minestrone soup";
$color ="blue";
}
elseif($menu_id =="3") {
$id="3";
$menu_name ="carrot soup";
$img_file ="images/carrot.jpg";
$description ="carrot soup.";
$color ="green";
}
elseif ($menu_id =="4"){
$id="4";
$menu_name ="shark fin";
$img_file ="images/sharkfin.jpg";
$description ="sharkfin.";
$color ="gray";
}
echo "<h1 style='text-align: center'>Welcome to my restaurant!</h1>";
echo "<font color=$color>You have selected $menu_name</font>. Menu ID($id)<br/>";
echo "<img src='$img_file'></img><br/>";
echo "$description";
?>
' 比方说,我想用的,而不是使用if-else语句Array()函数,我该怎么办呢?我明白有一个更简单的方法通过使用SQL语句,但我还没有教过SQL,现在我只能使用PHP。 在此先感谢!
你有没有听说过'病例'? – Peon
没有办法使用数组()代替if。 – superphonic
@superphonic肯定存在,如果if else将等于数值常量进行比较,则只需要在该数组槽中调用输出数据/动作/函数的数组即可。 – Dan