Hi All,

I am having trouble in updating a table. The form consists of check boxes that are populated from the first query. I need the form to submit in itself and set the checked fields to 1 and the unchecked to 0. Any and all help will be appreciated.

Thank you in advance

Max

<?php
include("include/session.php");
?>
<form name="menu1" action="" method="POST">
<fieldset>
<br />
<h3>Menu 1</h3>

<?php 
$query2="SELECT * FROM menu_1";
$result2 = mysql_query ($query2); 

?>
<table border="0" cellspacing="0" cellpadding="5" align="center" >
<tr>
<th></th>
<th>Level9</th>
<th>Level8</th>
<th>Level7</th>
<th>Level6</th>
<th>Level5</th>
<th>Level4</th>
<th>Level3</th>
<th>Level2</th>
<th>Level1</th>
</tr>

<?php


while($row = mysql_fetch_array($result2))  { 
$fitem=$row['item'];
$f9=$row['level9']; 
if ($f9==1){
	$fc9[$fitem]=checked;
}

$f8=$row['level8']; 
if ($f8==1){
	$fc8[$fitem]=checked;
}

$f7=$row['level7']; 
if ($f7==1){
	$fc7[$fitem]=checked;
}

$f6=$row['level6'];
if ($f6==1){
	$fc6[$fitem]=checked;
}

$f5=$row['level5'];
if ($f5==1){
	$fc5[$fitem]=checked;
}

$f4=$row['level4'];
if ($f4==1){
	$fc4[$fitem]=checked;
}

$f3=$row['level3'];
if ($f3==1){
	$fc3[$fitem]=checked;
}

$f2=$row['level2'];
if ($f2==1){
	$fc2[$fitem]=checked;
}

$f1=$row['level1'];
if ($f1==1){
	$fc1[$fitem]=checked;
} 
?>

<input type="hidden" name="fitem" value="<? echo $fitem; ?>">
<tr align="center">
<td><?php echo $fitem; ?></td>
<td><input type="checkbox" name="checkbox9" value="1"  <?php echo $fc9[$fitem]; ?> /><input type="hidden" name="checkbox9" value="0" /></td>
<td><input type="checkbox" name="checkbox8" value="1"  <?php echo $fc8[$fitem]; ?> /><input type="hidden" name="checkbox8" value="0" /></td>
<td><input type="checkbox" name="checkbox7" value="1"  <?php echo $fc7[$fitem]; ?> /><input type="hidden" name="checkbox7" value="0" /></td>
<td><input type="checkbox" name="checkbox6" value="1"  <?php echo $fc6[$fitem]; ?> /><input type="hidden" name="checkbox6" value="0" /></td>
<td><input type="checkbox" name="checkbox5" value="1"  <?php echo $fc5[$fitem]; ?> /><input type="hidden" name="checkbox5" value="0" /></td>
<td><input type="checkbox" name="checkbox4" value="1"  <?php echo $fc4[$fitem]; ?> /><input type="hidden" name="checkbox4" value="0" /></td>
<td><input type="checkbox" name="checkbox3" value="1"  <?php echo $fc3[$fitem]; ?> /><input type="hidden" name="checkbox3" value="0" /></td>
<td><input type="checkbox" name="checkbox2" value="1"  <?php echo $fc2[$fitem]; ?> /><input type="hidden" name="checkbox2" value="0" /></td>
<td><input type="checkbox" name="checkbox1" value="1"  <?php echo $fc1[$fitem]; ?> /><input type="hidden" name="checkbox1" value="0" /></td>
</tr>

<?php


}


$fpitem=$_POST['fitem'];
$fp9=$_POST['$chekbox9'];
$fp8=$_POST['$chekbox8'];
$fp7=$_POST['$chekbox7'];
$fp6=$_POST['chekbox6'];
$fp5=$_POST['chekbox5'];
$fp4=$_POST['chekbox4'];
$fp3=$_POST['chekbox3'];
$fp2=$_POST['chekbox2'];
$fp1=$_POST['chekbox1'];

$fpq= "UPDATE menu_1 SET level9='$fp9', level8='$fp8', level7='$fp7', level6='$fp6', level5='$fp5', level4='$fp4', level3='$fp3', level2='$fp2', level1='$fp1'";
mysql_query($query);
echo "Record Updated";

echo $fp9;
echo $fp8;
echo $fp7;
echo $fp6;

?>

</table>
<br />
<input name="menu1" VALUE="Apply Changes" type="submit"   />
</fieldset>
</form>

Recommended Answers

All 5 Replies

Member Avatar for diafol

Eeek! Mixed up html and php! You should separate the php and html as much as possible. The processing ideally should be done by a formhandler file (separate to the form file) as this prevents form resubmission on browser refresh/reload.

If you don't fancy this, I'd place all the php processing at the top of the page, above the DTD. All output should be placed into variables (before DTD) and then echoed out at the appropriate place in the page.

//EDIT

I don't understand why you have different fields for different levels. DO you need a single level value for an user, or could an user have multiple level values? If the former, a dropdown would be better than a set of checkboxes.

Hi Ardav,

The different user levels are to control the content that will be available to the differnt user and will be controled by an administator. I want to make it as easy as possible for the administator to control which items in the menu system will be available to different users.

With regards to the mixed up html and php...

I im learning as I go along. Please give me more detail on how to sptil the code into different files. If you have some code on how to do onselect with a dropdown box to poulate the differinf fields for a update form it would be greatly appreciated. I have spent hours in google trying to find more information or examples of a dropdown box that can populate fields either onclick or onselect.

Rgards
Max

Well you have the right idea.. sort of with your if statements, except (in my opinion) they would be better in the checkbox itself. Right now when you use the if else, you are not assigning a variable to the "true" statement. Because of that you cannot reference it in the checkbox. For the easiest solution, try this.

echo"<tr align='center'>";
while($row = mysql_fetch_array($result2))  { 
    echo"<input type='hidden' name='fitem' value='$row[item]'>";   
    echo"<td>$row[item]</td>";

    if($row['level1']=="1") {
        echo "<td><input type='checkbox' name='checkbox1' value='1' checked='checked' /></td>";
    } else {
        echo "<td><input type='checkbox' name='checkbox1' value='0' /></td>";
    }
}
echo "</tr>";

Then when the user clicks the submit button

if(isset($_POST['submit'])) {
 //Your update code
}

By the way, on your update, you have

$fpq= "UPDATE ....";

and you use this

mysql_query($query);

What is the "$query" variable too?

Member Avatar for diafol

> The different user levels are to control the content that will be available to the differnt user and will be controled by an administator. I want to make it as easy as possible for the administator to control which items in the menu system will be available to different users.

OK, so maybe radiobuttons would be better if only one value is required (easier than a dropdown).
e.g.

//do your DB data retrieval... 
 
$radio = ""; //initialize $radio for holding radiobuttons html
$i = 1; //start counter at level 1
while($i < 11){ //loop for 10 levels

 if(isset($level) && $level == $i){ //$level is the DB derived value of the user level    if already stored
   $checked = ' checked="checked"'; //this wil be added to the appropriate radiobox level
 }else{
   $checked = ''; //otherwise set checked variable to zero length
 }

 $radio .= "<input id=\"level{$i}\" name=\"level\" value=\"{$i}\"{$checked} /> <label for=\"level{$i}\">{$i}</label>"; //the html to append to the radio string every time - the {} aren't strictly necessary throughout this - but they help to show where the counter variable can be used - also the double quotes must be escaped (backslashed)

 $i++; //increment counter by 1 every time
}

At the appropriate point in your form:

<form ...>
...
<?php echo $radio;?>
...
</form>

You pick up the form data in order to update via $_POST variable:

$_POST will give you the level value (1 to 10).

I wouldn't use an 'onclick' unless you know know JS/Ajax.
There are a million ways to skin a cat. This is just one way. The code could be crunched down into a couple of lines, but would probably be incomprehensible.

Hi all,

Thank you for the help to date. I have tried to clean up my code, so here is the result. The query works fine and it populates all the fields but when submitting nothing happens. I was up until 4h00 am last night and I just can't get the update to work.

Please check what I am doing wrong.


Thank you

Max

<?php
include("include/session.php");
date_default_timezone_set('Africa/Johannesburg');
if(!$session->isAdmin()){
   header("Location: main.php");
}
else{
?>
<?php 
foreach ($_POST as $key => $value){
if (!is_array($value)){
$_POST[$key] = mysql_real_escape_string($value);
}
}
foreach ($_GET as $key => $value){
if (!is_array($value)){
$_GET[$key] = mysql_real_escape_string($value);
}
}
foreach ($_SESSION as $key => $value){
if (!is_array($value)){
$_SESSION[$key] = mysql_real_escape_string($value);
}
}  
?>
<?php
function displayMenu(){

$query2="SELECT * FROM menu_1";
$result2 = mysql_query ($query2); 

echo"<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n";
echo "<tr><td></td><td>Level 1</td><td>Level 2</td><td>Level 3</td><td>Level 4</td><td>Level 5</td><td>Level 6</td><td>Level 7</td><td>Level 8</td><td>Level 9</td></tr>\n";


while ($row = mysql_fetch_assoc($result2)) {



echo"<tr align=\"center\">";	

	echo"<input type='hidden' name='fitem' value='$row{item}'>";
	echo"<td>$row[item]</td>";

	if($row['level1']=="1") {
		echo "<td><input type='checkbox' name='checkbox1' value='1' checked='checked' /></td>\n";
	} else {
		echo "<td><input type='checkbox' name='checkbox1' value='0' /></td>\n";    
	}
	
	if($row['level2']=="1") {
		echo "<td><input type='checkbox' name='checkbox2' value='1' checked='checked' /></td>\n";
	} else {
		echo "<td><input type='checkbox' name='checkbox2' value='0' /></td>\n";    
	}
	
	if($row['level3']=="1") {
		echo "<td><input type='checkbox' name='checkbox3' value='1' checked='checked' /></td>\n";
	} else {
		echo "<td><input type='checkbox' name='checkbox3' value='0' /></td>\n";    
	}
	
	if($row['level3']=="1") {
		echo "<td><input type='checkbox' name='checkbox3' value='1' checked='checked' /></td>\n";
	} else {
		echo "<td><input type='checkbox' name='checkbox3' value='0' /></td>\n";    
	}
	
	if($row['level5']=="1") {
		echo "<td><input type='checkbox' name='checkbox5' value='1' checked='checked' /></td>\n";
	} else {
		echo "<td><input type='checkbox' name='checkbox5' value='0' /></td>\n";    
	}
	
	if($row['level6']=="1") {
		echo "<td><input type='checkbox' name='checkbox6' value='1' checked='checked' /></td>\n";
	} else {
		echo "<td><input type='checkbox' name='checkbox6' value='0' /></td>\n";    
	}
	
	if($row['level7']=="1") {
		echo "<td><input type='checkbox' name='checkbox7' value='1' checked='checked' /></td>\n";
	} else {
		echo "<td><input type='checkbox' name='checkbox7' value='0' /></td>\n";    
	}
	
	if($row['level8']=="1") {
		echo "<td><input type='checkbox' name='checkbox8' value='1' checked='checked' /></td>\n";
	} else {
		echo "<td><input type='checkbox' name='checkbox8' value='0' /></td>\n";    
	}
	
	if($row['level9']=="1") {
		echo "<td><input type='checkbox' name='$checkbox9' value='1' checked='checked' /></td>\n";
	} else {
		echo "<td><input type='checkbox' name='$checkbox9' value='0' /></td>\n";    
	}
echo "</tr>\n";	
}

echo "</table>";
echo "<input name=\"menu1\" VALUE=\"Apply Changes\" type=\"submit\"   />";
}


$fpitem=$_POST['$fitem'];
$fp9=$_POST{'$chekbox9'};
$fp8=$_POST{'$chekbox8'};
$fp7=$_POST['$chekbox7'];
$fp6=$_POST['$chekbox6'];
$fp5=$_POST['$chekbox5'];
$fp4=$_POST['$chekbox4'];
$fp3=$_POST['$chekbox3'];
$fp2=$_POST['$chekbox2'];
$fp1=$_POST['$chekbox1'];
if(isset($_POST['submit'])) {
	
$fpq= "UPDATE menu_1 SET level9='$fp9', level8='$fp8', level7='$fp7', level6='$fp6', level5='$fp5', level4='$fp4', level3='$fp3', level2='$fp2', level1='$fp1'";
$retval = mysql_query($fpq);
if(! $retval )
{
  die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";

}
else
{
		

}


}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script> 
var isNS = (navigator.appName == "Netscape") ? 1 : 0;  
if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);  
function mischandler(){   
return false; 
}  
function mousehandler(e){
var myevent = (isNS) ? e : event; 	
var eventbutton = (isNS) ? myevent.which : myevent.button;    
if((eventbutton==2)||(eventbutton==3)) return false; 
} 
document.oncontextmenu = mischandler; 
document.onmousedown = mousehandler; 
document.onmouseup = mousehandler;  
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
loadImage1 = new Image();
loadImage1.src = "images/icon0hover.jpg";
staticImage1 = new Image();
staticImage1.src = "images/icon0.jpg";

loadImage2 = new Image();
loadImage2.src = "images/icon1hover.jpg";
staticImage2 = new Image();
staticImage2.src = "images/icon1.jpg";

loadImage3 = new Image();
loadImage3.src = "images/icon2hover.jpg";
staticImage3 = new Image();
staticImage3.src = "images/icon2.jpg";

loadImage4 = new Image();
loadImage4.src = "images/icon3hover.jpg";
staticImage4 = new Image();
staticImage4.src = "images/icon3.jpg";

loadImage5 = new Image();
loadImage5.src = "images/icon4hover.jpg";
staticImage5 = new Image();
staticImage5.src = "images/icon4.jpg";

loadImage6 = new Image();
loadImage6.src = "images/icon5hover.jpg";
staticImage6 = new Image();
staticImage6.src = "images/icon5.jpg";

loadImage7 = new Image();
loadImage7.src = "images/icon6hover.jpg";
staticImage7 = new Image();
staticImage7.src = "images/icon6.jpg";

loadImage8 = new Image();
loadImage8.src = "images/icon7hover.jpg";
staticImage8 = new Image();
staticImage8.src = "images/icon7.jpg";

loadImage9 = new Image();
loadImage9.src = "images/icon8hover.jpg";
staticImage9 = new Image();
staticImage9.src = "images/icon8.jpg";

loadImage10 = new Image();
loadImage10.src = "images/icon9hover.jpg";
staticImage10 = new Image();
staticImage10.src = "images/icon9.jpg";

loadImage11 = new Image();
loadImage11.src = "images/icon10hover.jpg";
staticImage11 = new Image();
staticImage11.src = "images/icon10.jpg";

loadImage12 = new Image();
loadImage12.src = "images/icon11hover.jpg";
staticImage12 = new Image();
staticImage12.src = "images/icon11.jpg";

loadImage13 = new Image();
loadImage13.src = "images/icon12hover.jpg";
staticImage13 = new Image();
staticImage13.src = "images/icon12.jpg";

// End -->
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="js/ddaccordion.js">
/***********************************************
* Accordion Content script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/
</script>
<script type="text/javascript">
ddaccordion.init({
	headerclass: "silverheader",
	contentclass: "submenu",
	revealtype: "mouseover",
	mouseoverdelay: 200,
	collapseprev: true,
	defaultexpanded: [0],
	onemustopen: true,
	animatedefault: false, 
	persiststate: true, 
	toggleclass: ["", "selected"],
	togglehtml: ["", "", ""],
	animatespeed: "normal",
	oninit:function(headers, expandedindices){ 
	},
	onopenclose:function(header, index, state, isuseractivated){ 
	}
})
</script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>COMPASS ROSE CMMS</title>
<style type="text/css">
<!--
body {
	font: normal 12px Tahoma, "Lucida Grande", "Trebuchet MS", Helvetica, sans-serif;
	background: #fff;
	margin: 0;
	padding: 0;
	color: #000;
}
ul, ol, dl {
	padding: 0;
	margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
	margin-top: 0;
	padding-right: 15px;
	padding-left: 15px;
}
a img {
	border: none;
}
a:link {
	color:#414958;
	text-decoration: none; 
}
a:visited {
	color: #4E5869;
	text-decoration: none;
}
a:hover, a:active, a:focus {
	text-decoration: none;
}
.container {
	width: 100%;
	min-width: 780px;
	background: #FFF;
	margin: 0 auto;
	overflow: hidden;
}
.sidebar1 {
	float: left;
	position:fixed;
	width: 250px;
	height: 100%;
	background: #fff;
	margin-top:33px;
	padding-bottom: 10px;
    border-right: 3px solid #3a3a5d;
	z-index:2;
}
.logo {
	width: 200px;
	height: 200px;
	padding-left:25px;
	position:absolute bottom;
}
.top {
	float: left;
	color: #fff;
	position:fixed;
	width: 100%;
	height: 30px;
	background-image:url(images/top.jpg);
	background-repeat:repeat-x;
	vertical-align:middle;
	border-bottom: 3px solid #3a3a5d;
	z-index:1;
}
.icon0 {
	height: 28px;
	border-bottom: 3px solid #3a3a5d;
}
.content {
	padding: 10px;
	margin-left: 275px;
	margin-top: 40px;
	width: auto;
	float: left;
}
.fltrt {  /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
	float: right;
	margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
	float: left;
	margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the overflow:hidden on the .container is removed */
	clear:both;
	height:0;
	font-size: 1px;
	line-height: 0px;
}
.applemenu{
padding: 0;
width: 250px;
background-color:#e3d96c;
}
.applemenu div.silverheader a{
azimuth:center;
background: url(images/top.jpg) repeat-x center left;
font: normal 12px Tahoma, "Lucida Grande", "Trebuchet MS", Helvetica, sans-serif;
color: black;
background-color:#e3d96c;
display: block;
position: relative; 
width: auto;
padding-left: 8px;
text-decoration:none;
}
.applemenu div.silverheader a:visited, .applemenu div.silverheader a:active{
color: #000;
}
.applemenu div.selected a, .applemenu div.silverheader a:hover{
background-image: url(images/silvergradientover.gif);
color: 000;
}
.applemenu div.submenu{
background-color:#fff;
font: normal 12px Tahoma, "Lucida Grande", "Trebuchet MS", Helvetica, sans-serif;
padding: 5px;
height: auto;
}


-->
</style>
</head>

<body>

	<div class="container">
		<div class="top">
        <div>
			<img src="images/compass rose.jpg" />
            <?php
			if($session->logged_in){
   			echo "Logged in as: $session->username";
			}
			?>

            <img src="images/iconspacer.jpg" align="right" />           
			<a href="" onmouseover="image1.src=loadImage1.src;" onmouseout="image1.src=staticImage1.src;">
				<img name="image1" src="images/icon0.jpg" align="right">
            </a>
			<a href="" onmouseover="image2.src=loadImage2.src;" onmouseout="image2.src=staticImage2.src;">
				<img name="image2" src="images/icon1.jpg" align="right">
            </a>
			<a href="" onmouseover="image3.src=loadImage3.src;" onmouseout="image3.src=staticImage3.src;">
				<img name="image3" src="images/icon2.jpg" align="right">
            </a>
			<a href="" onmouseover="image4.src=loadImage4.src;" onmouseout="image4.src=staticImage4.src;">
				<img name="image4" src="images/icon3.jpg" align="right">
            </a>
			<a href="" onmouseover="image5.src=loadImage5.src;" onmouseout="image5.src=staticImage5.src;">
				<img name="image5" src="images/icon4.jpg" align="right">
            </a>
			<a href="" onmouseover="image6.src=loadImage6.src;" onmouseout="image6.src=staticImage6.src;">
				<img name="image6" src="images/icon5.jpg" align="right">
            </a>
			<a href="" onmouseover="image7.src=loadImage7.src;" onmouseout="image7.src=staticImage7.src;">
				<img name="image7" src="images/icon6.jpg" align="right">
            </a>
			<a href="" onmouseover="image8.src=loadImage8.src;" onmouseout="image8.src=staticImage8.src;">
				<img name="image8" src="images/icon7.jpg" align="right">
            </a>
			<a href="" onmouseover="image9.src=loadImage9.src;" onmouseout="image9.src=staticImage9.src;">
				<img name="image9" src="images/icon8.jpg" align="right">
            </a>
			<a href="" onmouseover="image10.src=loadImage10.src;" onmouseout="image10.src=staticImage10.src;">
				<img name="image10" src="images/icon9.jpg" align="right">
            </a>
			<a href="" onmouseover="image11.src=loadImage11.src;" onmouseout="image11.src=staticImage11.src;">
				<img name="image11" src="images/icon10.jpg" align="right">
            </a>            
			<a href="test.php" onmouseover="image12.src=loadImage12.src;" onmouseout="image12.src=staticImage12.src;">
				<img name="image12" src="images/icon11.jpg" align="right">
            </a>
			<a href="main.php" onmouseover="image13.src=loadImage13.src;" onmouseout="image13.src=staticImage13.src;">
				<img name="image13" src="images/icon12.jpg" align="right">
            </a> 
                                               
        </div>  
		</div>
  		<div class="sidebar1">

			<div class="applemenu">
				<div class="silverheader">                	
                	<a href="">
                    	LOG IN / OUT
                    </a>
                </div>
				<div class="submenu">

<?php
/**
 * User has already logged in, so display relavent links, including
 * a link to the admin center if the user is an administrator.
 */
if($session->logged_in){
   echo "<h1>Logged In</h1>";
   echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"
       ."[<a href=\"useredit.php\">Edit Account</a>] &nbsp;&nbsp;"
	   ."[<a href=\"process.php\">Logout</a>] <br /><br />";
   if($session->isAdmin()){

$query= "select * from admin_menu";
$list=mysql_query($query);
while($record=mysql_fetch_array($list))
{					
echo"<a href=\"".$record['href']."\">".$record['item']."</a>";
echo"<br />"; 
}  
   }
}
else{
?>
<?php
/**
 * User not logged in, display the login form.
 * If user has already tried to login, but errors were
 * found, display the total number of errors.
 * If errors occurred, they will be displayed.
 */
if($form->num_errors > 0){
   echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>";
}
?>
<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"></td><td><?php echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"></td><td><?php echo $form->error("pass"); ?></td></tr>
<tr><td colspan="2" align="left"><input type="checkbox" name="remember" <?php if($form->value("remember") != ""){ echo "checked"; } ?>>
<font size=2>Remember me next time &nbsp;&nbsp;&nbsp;&nbsp;
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login"></td></tr>
<tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
</table>
</form>

<?php
}

/**
 * Just a little page footer, tells how many registered members
 * there are, how many users currently logged in and viewing site,
 * and how many guests viewing site. Active users are displayed,
 * with link to their user information.
 */
echo "<br /><br /><br />";
echo "Users logged in: $database->num_active_users <br />";



?>
<br />
				</div>
				<div class="silverheader">
                	<a href="" >
                    	MENU 1
                    </a>
                </div>
				<div class="submenu">
<?php
if($session->logged_in){
   if($session->isAdmin()){
      $test = "level9";
   }
      if($session->isUser8()){
      $test = "level8";
   }
      if($session->isUser7()){
      $test = "level7";
   }   
      if($session->isUser6()){
      $test = "level6";
   }   
      if($session->isUser5()){
      $test = "level5";
   }   
      if($session->isUser4()){
      $test = "level4";
   }   
      if($session->isUser3()){
      $test = "level3";
   }   
      if($session->isUser2()){
      $test = "level2";
   }   
       if($session->isUser1()){
      $test = "level1";
   }    
$query= "select * from menu_1 WHERE $test = '1'";
$list=mysql_query($query);
while($record=mysql_fetch_array($list))
{					
echo"<a href=\"".$record['href']."\">".$record['item']."</a>";
echo"<br />"; 
}
}
?>
<br />
				</div>
				<div class="silverheader">
                	<a href="">
                		MENU 2
                	</a>
                </div>
				<div class="submenu">
<?php
if($session->logged_in){
   if($session->isAdmin()){
      $test = "level9";
   }
      if($session->isUser8()){
      $test = "level8";
   }
      if($session->isUser7()){
      $test = "level7";
   }   
      if($session->isUser6()){
      $test = "level6";
   }   
      if($session->isUser5()){
      $test = "level5";
   }   
      if($session->isUser4()){
      $test = "level4";
   }   
      if($session->isUser3()){
      $test = "level3";
   }   
      if($session->isUser2()){
      $test = "level2";
   }   
       if($session->isUser1()){
      $test = "level1";
   }    
$query= "select * from menu_1 WHERE $test = '1'";
$list=mysql_query($query);
while($record=mysql_fetch_array($list))
{					
echo"<a href=\"".$record['href']."\">".$record['item']."</a>";
echo"<br />"; 
}
}
?>
<br />
				</div>
				<div class="silverheader">
                	<a href="">
                		MENU 3
                	</a>
                </div>
				<div class="submenu">
<?php
if($session->logged_in){
   if($session->isAdmin()){
      $test = "level9";
   }
      if($session->isUser8()){
      $test = "level8";
   }
      if($session->isUser7()){
      $test = "level7";
   }   
      if($session->isUser6()){
      $test = "level6";
   }   
      if($session->isUser5()){
      $test = "level5";
   }   
      if($session->isUser4()){
      $test = "level4";
   }   
      if($session->isUser3()){
      $test = "level3";
   }   
      if($session->isUser2()){
      $test = "level2";
   }   
       if($session->isUser1()){
      $test = "level1";
   }    
$query= "select * from menu_1 WHERE $test = '1'";
$list=mysql_query($query);
while($record=mysql_fetch_array($list))
{					
echo"<a href=\"".$record['href']."\">".$record['item']."</a>";
echo"<br />"; 
}
}
?>
<br />
				</div>
				<div class="silverheader">
                	<a href="">
                		MENU 4
                	</a>
                </div>
				<div class="submenu">
<?php
if($session->logged_in){
   if($session->isAdmin()){
      $test = "level9";
   }
      if($session->isUser8()){
      $test = "level8";
   }
      if($session->isUser7()){
      $test = "level7";
   }   
      if($session->isUser6()){
      $test = "level6";
   }   
      if($session->isUser5()){
      $test = "level5";
   }   
      if($session->isUser4()){
      $test = "level4";
   }   
      if($session->isUser3()){
      $test = "level3";
   }   
      if($session->isUser2()){
      $test = "level2";
   }   
       if($session->isUser1()){
      $test = "level1";
   }    
$query= "select * from menu_1 WHERE $test = '1'";
$list=mysql_query($query);
while($record=mysql_fetch_array($list))
{					
echo"<a href=\"".$record['href']."\">".$record['item']."</a>";
echo"<br />"; 
}
}
?>
<br />
				</div>		
			</div>
        </div>

		<div class="content">
<h3>Access Level Management</h3>

<form name="menu1" method="POST" action="<?php $_PHP_SELF ?>">
<fieldset>
<br />
<h3>Menu 1</h3>

<?php echo displayMenu();?>	

<br />

</fieldset>
</form>


	</div>
	</div>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.