我有两个标题,我想根据帐户类型显示; ""对于管理员类型和" b"对于常规用户类型。 我已经有了enum set' a'' b'。现在,对于连接到数据库后的php,我有:
<?php
while ($row = mysql_fetch_array($sql)){
$name = $row["name"];
$accounttype = $row["accounttype"];
if($accounttype == "a"){
$header = include_once "header_a.php";
}
if($accounttype == "b"){
$header = include_once "header_b.php";
}
}
?>
至于html,我有:
<html>
<body>
<?php echo $accounttype; ?>
</body>
</html>
编辑: 好吧,我让它以正确的方式运作:
<?php
$header ="";
while ($row = mysql_fetch_array($sql)){
$name = $row["name"];
$accounttype = $row["accounttype"];
if($accounttype == "a"){
include_once "header_a.php";
}else{
include_once "header_b.php";
}
}
?>
<html>
<body>
<?php echo $header; ?>
</body>
</html>
答案 0 :(得分:1)
为什么不这样:
<?php
while ($row = mysql_fetch_array($sql)){
$name = $row["name"];
$accounttype = $row["accounttype"];
}
include_once "header_".$accounttype.".php";
?>
<html>
<body>
<?php echo $accounttype; ?>
</body>
</html>