I have a page where the logged in user can see a list of different links, but only if the links match an entry in a MySQL database, something like this:
<li>
<?php
require ("scripts/connect.php");
$query = mysql_query("SELECT * FROM files WHERE subject='consulting' AND active='1'");
$numrows = mysql_num_rows($query);
if ($numrows > 0)
echo "
<a class='atags' href=\"javascript:showonlyone('consulting', this)\">Consulting</a>";
if ($numrows == 0)
echo "";
?>
</li>
<li>
<?php
require ("scripts/connect.php");
$query = mysql_query("SELECT * FROM files WHERE subject='Projects' AND active='1'");
$numrows = mysql_num_rows($query);
if ($numrows > 0)
echo "<li><a class='atags' href=\"javascript:showonlyone('projects', this)\">Projects</a></li>";
if ($numrows == 0)
echo "";
?>
</li>
ETC...
However, I just realized that if the $username in my session_start(); has 1 in the moderator field I want to show something different. How can I do this? Theoretically what I am looking for is something like this:
if ($username && $moderator == 1) {
echo "You can edit this.";
}
else
echo "<li>
<?php
require ("scripts/connect.php");
$query = mysql_query("SELECT * FROM files WHERE subject='art' AND active='1'");
$numrows = mysql_num_rows($query);
if ($numrows > 0)
echo "
<a class='atags' href=\"javascript:showonlyone('art', this)\">Art</a>";
if ($numrows == 0)
echo "";
?>
</li>
<li>
<?php
require ("scripts/connect.php");
$query = mysql_query("SELECT * FROM files WHERE subject='computer' AND active='1'");
$numrows = mysql_num_rows($query);
if ($numrows > 0)
echo "<li><a class='atags' href=\"javascript:showonlyone('computer', this)\">Computer</a></li>";
if ($numrows == 0)
echo "";
?>
</li>
<li>
<?php
require ("scripts/connect.php");
$query = mysql_query("SELECT * FROM files WHERE subject='critical reading' AND active='1'");
$numrows = mysql_num_rows($query);
if ($numrows > 0)
echo "<li><a class='atags' href=\"javascript:showonlyone('criticalreading', this)\">Critical Reading</a></li>";
if ($numrows == 0)
echo "";
?>
</li>
<li>
<?php
require ("scripts/connect.php");
$query = mysql_query("SELECT * FROM files WHERE subject='french' AND active='1'");
$numrows = mysql_num_rows($query);
if ($numrows > 0)
echo "<li><a class='atags' href=\"javascript:showonlyone('french', this)\">French</a></li>";
if ($numrows == 0)
echo "";
?>
</li>";
Is this possible? Thanks.