为什么php不能读取else语句?
<select name="brgy_name" class="" style="width:240px" id="brgy_name" required >
<?php
if($_SESSION['admin_usertype']=="ADMIN") ?>{
<?php echo $_SESSION['admin_usertype'] ?>
<option value="<?php echo $_SESSION['cbrgyname'];?>"><font style="margin-top:-20px"><?php echo $_SESSION['cbrgyname']?></font></option>
}else {
}
</select>
答案 0 :(得分:1)
不确定你想在这做什么..但试试这个..
<select name="brgy_name" class="" style="width:240px" id="brgy_name" required >
<?php
if ($_SESSION['admin_usertype'] == "ADMIN") {
echo $_SESSION['admin_usertype']; // this just echos "ADMIN".
$cbrgy_name = $_SESSION['cbrgyname'];
echo "<option value='".$cbrgy_name."'><font style='margin-top:-20px'>".$cbrgy_name."</font></option>";
}
else {
// do something...
}
<?
</select>
答案 1 :(得分:1)
请试试这个......
<select name="brgy_name" class="" style="width:240px" id="brgy_name" required>
<?php
if ($_SESSION['admin_usertype'] == "ADMIN"){
echo $_SESSION['admin_usertype'];
?>
<option value="<?php echo $_SESSION['cbrgy_name']; ?>" ><font style="margin-top:-20px"> <?php echo $_SESSION['cbrgy_name']; ?></font></option>
<?php
}else{
// do something....
}
?>
</select>
结束你的PHP代码时请注意“;”(分号)...我已经看到你有回音的东西,但你没有关闭它...希望它有帮助..
答案 2 :(得分:1)
它已经完成了我得到了=)..感谢你们的帮助,非常感谢...这里是
<select name="brgy_name" class="" style="width:240px" id="brgy_name" required >
<?php
if($var=='ADMIN')
{ ?>
<option value="<?php echo $_SESSION['cbrgyname'];?>"><font style="margin-top:-20px"><?php echo $_SESSION['cbrgyname']?></font></option>
<?php }
else { ?>
<option value="">Select Barangay</option>
<option value="ALL">ALL</option>
<?php $result = pg_query("SELECT * FROM tbl_barangay order by cbrgyname");
while($row = pg_fetch_array($result)){ ?>
<option value="<?php echo $row['cbrgyname']; ?>"><font style="margin-top:-20px"><?php echo $row['cbrgyname'];?></font></option>
<?php } ?>
<? }?>
</select>