So, I have a MySQL database that list users as managers or employees. I want to change the menubar that they see based on the properties. I did have all this done in php, but when going through a re-design I thought about putting it in html files, but I can't quite figure out how this should work.
Here is the php code that I was using to do the operation in the file menubar2.php:
<?php
$email = $_SESSION['logname'];
$results = "SELECT email FROM manager_list WHERE email = '$email'";
$results = mysqli_query($cxn, $results) or die("Query died: query");
$numrows = mysqli_num_rows($results);
if ($numrows == 0)
{
echo"<div id='menu'>";
echo"<ul>";
echo"<li><a href='index2.php'>Quick Review</a></li>";
echo"<li><a href='myPerformance.php'>My Peformance</a></li>";
echo"<li><a href='myGoals.php'>My Goals</a></li>";
echo"<li><a href='sHelp.php'>Help</a></li>";
echo"</ul>";
echo"</div>";
}
if ($numrows > 0)
{
echo"<div id='menu'>";
echo"<ul>";
echo"<li><a href='index2.php'>Quick Review</a></li>";
echo"<li><a href='myPerformance.php'>My Peformance</a></li>";
echo"<li><a href='myGoals.php'>My Goals</a></li>";
echo"<li><a href='toolsManager.php'>Manager Tools</a></li>";
echo"<li><a href='sHelp.php'>Help</a></li>";
echo"</ul>";
echo"</div>";
}
?>
And here is where I was using it (index.html)
<?php
include('sessionauth.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>TinyEval</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<?php
include('header2.php');
include('menubar2.php');
?>
<!-- begin #page -->
<div id="page">
<div id="content">
<div class="post">
<h2 class="title">Frequently Asked Questions</h2>
<div class="entry">
<p>How do I fix my headers?</p>
</div>
</div>
</div>
</div>
<div style="clear: both;"> </div>
<!-- end #page -->
</div>
<?php include('footer2.php'); ?>
</body>
</html>
Is there a way I can do this without the include for the menubar2.php? That is just put the code in the html?
Sorry for the newb question, but I'm driving myself batty trying to figure out how html and php/MySQL all tie together. Thanks!
Aucun commentaire:
Enregistrer un commentaire