Php 包含一次内部回音
我有两个标题,我想显示根据帐户类型;“a”表示管理员类型,“b”表示普通用户类型。 我已经有了枚举集'a','b'。现在,对于连接到数据库后的php,我有:Php 包含一次内部回音,php,string,include,echo,Php,String,Include,Echo,我有两个标题,我想显示根据帐户类型;“a”表示管理员类型,“b”表示普通用户类型。 我已经有了枚举集'a','b'。现在,对于连接到数据库后的php,我有: <?php while ($row = mysql_fetch_array($sql)){ $name = $row["name"]; $accounttype = $row["accounttype"]; if($accounttype == "a"){
<?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>
为什么不这样做:
<?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>
您的问题是什么?如何根据帐户类型显示不同的标题,一个用于管理员,另一个用于普通用户?看,我想管理员有额外的链接。谢谢!这似乎奏效了。