I have two headers which I'd like to display according to account type; "a" for admin type and "b" for regular user type. I already have the enum set 'a','b'. Now, for the php after connecting to the database, I have:
<?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";
}
}
?>
As for the html, I have:
<html>
<body>
<?php echo $accounttype; ?>
</body>
</html>
Edit: For some reason this worked like a charm... not sure why nor how.
<?php
while ($row = mysql_fetch_array($sql)){
$name = $row["name"];
$accounttype = $row["accounttype"];
if($accounttype == "a"){
include_once "header_a.php";
}
if($accounttype == "b"){
include_once "header_b.php";
}
include_once "header_".$accounttype.".php";
}
?>
<html>
<body>
<?php echo $header; ?>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire