<?php
	//session_start();

	$query = "SELECT * FROM opciones WHERE flagver = '1' AND id_padre = '0'";

	if(isset($_SESSION)){
		if($_SESSION["perfil"] == "E"){
			$query .= " AND nivel <= '1'";
		} elseif ($_SESSION["perfil"] == "A"){
			$query .= " AND nivel <= '2'";
		} else {
			$query .= " AND nivel = '0'";
		}
	}

	$query .= " ORDER BY `id`";

	$result = mysql_query($query) or die(mysql_error());
    echo "<ul>";
    while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
    	if ($row["titulo"] == "Ayuda") {
    		$action = $row["accion"];
    		$target = "target=\"_blank\"";
    	} else {
    		$action = $row["accion"].".php";
    		$target ="";
    	}
    	echo "<li><a href='".$action."' title='" . $row['titulo'] . "'".$target.">" . $row['titulo'] . "</a></li>";
    }
    echo "</ul>";
?>