Can not get select menu to appear when in query.
Posted: Thu Jan 02, 2003 8:36 pm
On this control panel I have two staff levels. (1 and 2 are the supposed values). On my add data form I have option menus that determine which author posted this data, which category it's going to, etc.
I have two queries where I need a stafflevel variable to be recognized from the staff table, and likewise with author for the news table. $author needs to pick up the records from the username variable/field from the staff table as that was already queried from login activation, and it does though only with the name that I'm logged in as and not the full list. The if statement, which I'm using to determine which level of staff is logged on, doesn't pick up anything and doesn't show that selection menu for author on the value 1.
Still not sharp with fetching arrays via mysql, but I'm trying. What's off with my syntax?
I have two queries where I need a stafflevel variable to be recognized from the staff table, and likewise with author for the news table. $author needs to pick up the records from the username variable/field from the staff table as that was already queried from login activation, and it does though only with the name that I'm logged in as and not the full list. The if statement, which I'm using to determine which level of staff is logged on, doesn't pick up anything and doesn't show that selection menu for author on the value 1.
Still not sharp with fetching arrays via mysql, but I'm trying. What's off with my syntax?
Code: Select all
<?php
$query = "SELECT * FROM news WHERE author='$author'";
$result = mysql_query($query) or die('error making query');
$row = mysql_fetch_array($result);
$author=$row['author'];
$author=$username;
$query2 = "SELECT * FROM staff WHERE stafflevel='$stafflevel'";
$result = mysql_query($query2) or die('error making query');
$row = mysql_fetch_array($result);
$stafflevel=$row['stafflevel'];
if ($stafflevel == 1) //is an admin, gets to select which author posted
{
echo "<select name='author'>";
echo "<option value='$author'>$author</option>'";
echo "</select>";
}
else
{
echo ""; //does not have the option to choose which author
//submits this data, will only be submitted as the name that's logged in
}
?>