<?php

include ("conex.php");

//echo $_GET['ordenar'];
$menu $_GET['menu'];
if (
$_GET['menu'] == '')
    {
    
$menu '';    
    }
if (
$_GET['menu'] != '')
    {
    
$menu " AND SECTOR = '$_GET[menu]'";    
    }    
        

if (
$_GET['ordenar'] == 'mas')
    {
    
$order ' order by ano DESC, norma DESC';        
    }
    
if (
$_GET['ordenar'] == 'menos')
    {
    
$order ' order by ano ASC, norma ASC';    
    }
if (
$_GET['ordenar'] == '')
    {
    
$order '';    
    }
    
    
$criterio "$menu$order";    

$menu=ucfirst(strtolower($_GET['menu']));
$sql=mysql_query("SELECT `id` , `norma` , `ano` , `resuelve` , `sector` , `vinculo` , `publicacion` FROM `normatividad` WHERE `publicacion` = 's' $criterio ",$con);


//muestra los datos consultados
echo "<table>
    <caption>
    <h5>
$menu</h5></caption>
    <thead>
    <tr class='odd'>

        <th scope='col' abbr='Home'><h5><span></span>No.</h5></th>
        <th scope='col' abbr='Home'><h5><span></span>Norma</h5></th>
        <th scope='col' abbr='Home'><h5><span></span>Título</h5></th>
        <th scope='col' abbr='Home'><h5><span></span>Sector</h5></th>
        <th scope='col' abbr='Home'><h5><span></span>Enlace</h5></th>
        

    </tr>    
    </thead>
    <tfoot>"
;
while(
$row mysql_fetch_array($sql)){

$cont=$cont+1;

if (
$cont == 0)
$class"class='odd'";

if (
$cont == 1)
$class"";




echo 
"
<tr 
$class>
        <th  scope='row'>
$cont</th>
        <td>
$row[norma]</td>
        <td>
$row[resuelve]</td>
        <td>
$row[sector]</td>
        <td><A href='
$row[vinculo]' target=_blank><img src='images/docs.png' width='32' height='35' border='0' align='absmiddle'/></a></td>
        
        "
;
        
}
?>