<?php
session_start();
include "../config.php";
include "../header.php";
include "../style.php";
if( isset($_SESSION["alogin"]) ) {

$index = $_POST['index'];
$name = $_POST['name'];
$url = $_POST['url'];
$seq = $_POST['seq'];
$memtypes_option = $_POST['memtypes_option'];
$memtypes = $_POST['memtypes'];



?>
<table>
<tr>
<td width="15%" valign=top><br>
<? include("adminnavigation.php"); ?>
</td>
<td valign="top" align="center"><br><br> 
<?
echo "<font size=2 face='$fonttype' color='$fontcolour'><p><b><center>";

$memtypes_all_sql = "SELECT SUM(level) AS AllValue FROM memtypes;";
$memtypes_all_result = mysql_query($memtypes_all_sql);
$memtypes_all_row = mysql_fetch_array($memtypes_all_result);
$memtypes_all_value = $memtypes_all_row['AllValue'];
if (is_null($memtypes_all_value)) { $memtypes_all_value = 7; }

if ($memtypes_option=="0") { // ALL MEMBER TYPES
$memtype_value = $memtypes_all_value;
} else {
$memtype_value = 0;
for ($memtype_index=0; $memtype_index < count($memtypes); $memtype_index++) {
$memtype_value = $memtype_value + $memtypes[$memtype_index];
}
}
if ($memtype_value==0) { $memtype_value = $memtypes_all_value; }

$query = "update navigation set name='".$name."', url='".$url."', seq=".$seq.", memtypes=".$memtype_value." where id=".$index;
$result = mysql_query ($query) or die ("Edit failed 1");

echo "Your changes have been saved.";
?> 
<p>Click <a href=navigation.php>here</a> to go back<p>
</td>
</tr>
</table>
<?
} else {
echo "Unauthorised Access!";
}

include "../footer.php";
mysql_close($dblink);
?>