我想給管理員激活用戶帳號的能力裏面PHP else語句,所以我不得不地位活性和非活性 當我運行我的代碼,我得到4個狀態 活動 無效 活動 無效 你會發現這裏的截圖來理解這個問題我現在面臨如果和的回聲
http://i.imgur.com/2c0VcN7.png
if(isset($_GET['id_user'])){
include("conexion.php");
$rep=$db->query("select * from user WHERE id_user=" .$_GET['id_user'] );
while($l=$rep->fetch()){
echo "
<form class= mainSettingsForm add method='POST'>
<label>Numero utlisateur :</label>
<input disabled='disabled' type='text' name='ref' value=' ".$l[0]." ' ></input>
<input name='id_user2' type='hidden' value='".$l[0]."' ></input>
<label>Nom utlisateur : </label>
<input type='text' name='username2' value='".$l[1]."' >
<label> nom : </label>
<input type='text' name='nom2' value='".$l[3]."' >
<label> prenom : </label>
<input type='text' name='prenom2' value='".$l[4]."' >
<label> Statut : </label>
<select name=statut >
if ($l[6] ==active) {
echo '
<option value=active >active</option>
<option value=inactive >inactive</option> }'
else {
echo '
<option value=inactive >inactive</option>
<option value=active >active</option> }'
</select>
<input class=btn-primary type='submit' name='enregistrer' value='enregistrer' >
</form>"; // fin echo
}
}
?>
close echo,run if,open echo。學習語言語法的基礎知識將有助於 – 2016-05-16 00:32:17
[如果塊內部的echo語句?]可能重複(http://stackoverflow.com/questions/3507042/if-block-inside-echo-statement)或[如何嵌入如果聲明裏面回聲](http://stackoverflow.com/questions/21175753/how-to-embed-if-statement-inside-echo) – Sean