我的網站上else邏輯我哪裏行是使用下面的代碼生成的頁面:如果取決於幾個行
<?php
while($row=mysql_fetch_assoc($sql)) {
if($row['type']=='1'){ $tipo="one";}
if($row['type']=='2'){ $tipo="two";}
if($row['type']=='3'){ $tipo="three";}
if($row['type']=='4'){ $tipo="four";}
if($row['type']=='5'){ $tipo="five";}
if($row['type']=='6'){ $tipo="six";}
if($row['type']=='7'){ $tipo="seven";}
if($row['type']=='8'){ $tipo="eight";}
if($row['type']=='9'){ $tipo="nine";}
if($row['type']=='10'){ $tipo="ten";}
?>
<tbody>
<tr>
<td>
<?php
if($row['type']=='9') {
echo 'Text One';
}
else {
echo 'Text two';
} ?>
</td>
</tr>
</tbody>
<?php
}
?>
我需要一個代碼,這將做下一件事之後:
如果如果有一行並且$row['type']!=='9'
回顯文本「不是九」,但是如果有多行並且對於其中至少有一行$row['type']=='9'
echo文本「both」else echo「非他們「
我無法弄清楚如何做到這一點。你能幫我一下嗎?您要
嘗試這樣的事情是什麼
你在你的問題中有你的答案......你的解釋只是需要在PHP中重寫。使用僞代碼(https://en.wikipedia.org/wiki/Pseudocode)可以幫助你正式確定你想要的以及如何對它進行編碼。 如果您仍然爲此而煩惱,請添加您的代碼,我們將能夠爲您提供幫助。 – NaeiKinDus