<?php session_start();
  if (isset($_GET["order"])) $order = @$_GET["order"];
  if (isset($_GET["type"])) $ordtype = @$_GET["type"];

  if (isset($_POST["filter"])) $filter = @$_POST["filter"];
  if (isset($_POST["filter_field"])) $filterfield = @$_POST["filter_field"];
  $wholeonly = false;
  if (isset($_POST["wholeonly"])) $wholeonly = @$_POST["wholeonly"];

  if (!isset($order) && isset($_SESSION["order"])) $order = $_SESSION["order"];
  if (!isset($ordtype) && isset($_SESSION["type"])) $ordtype = $_SESSION["type"];
  if (!isset($filter) && isset($_SESSION["filter"])) $filter = $_SESSION["filter"];
  if (!isset($filterfield) && isset($_SESSION["filter_field"])) $filterfield = $_SESSION["filter_field"];

?>

<html>
<head>
<title>ceulac_sadce -- alumnos</title>
<meta name="generator" http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
  body {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
  .bd {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
  .tbl {
    background-color: #FFFFFF;
  }
  a:link { 
    background-color: #FFFFFF01;
    color: #FF0000;
    font-family: Arial;
    font-size: 12px;
  }
  a:active { 
    background-color: #FFFFFF01;
    color: #0000FF;
    font-family: Arial;
    font-size: 12px;
  }
  a:visited { 
    background-color: #FFFFFF01;
    color: #800080;
    font-family: Arial;
    font-size: 12px;
  }
  .hr {
    background-color: #336699;
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:link {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:active {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:visited {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  .dr {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
  .sr {
    background-color: #FFFFCF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
</style>
</head>
<body>
<table class="bd" width="100%"><tr><td class="hr"><h2>Autoridades de la ULAC</h2></td></tr></table>
<?php
  $conn = connect();
  $showrecs = 30;
  $pagerange = 30;

  $a = @$_GET["a"];
  $recid = @$_GET["recid"];
  $page = @$_GET["page"];
  if (!isset($page)) $page = 1;

  $sql = @$_POST["sql"];

  switch ($sql) {
    case "insert":
      sql_insert();
      break;
    case "update":
      sql_update();
      break;
    case "delete":
      sql_delete();
      break;
  }

  switch ($a) {
    case "add":
      addrec();
      break;
    case "view":
      viewrec($recid);
      break;
    case "edit":
      editrec($recid);
      break;
    case "del":
      deleterec($recid);
      break;
    default:
      select();
      break;
  }

  if (isset($order)) $_SESSION["order"] = $order;
  if (isset($ordtype)) $_SESSION["type"] = $ordtype;
  if (isset($filter)) $_SESSION["filter"] = $filter;
  if (isset($filterfield)) $_SESSION["filter_field"] = $filterfield;
  if (isset($wholeonly)) $_SESSION["wholeonly"] = $wholeonly;

  mysql_close($conn);
?>
<table class="bd" width="100%"><tr><td class="hr"></td></tr></table>
</body>
</html>

<?php function select()
  {
  global $a;
  global $showrecs;
  global $page;
  global $filter;
  global $filterfield;
  global $wholeonly;
  global $order;
  global $ordtype;


  if ($a == "reset") {
    $filter = "";
    $filterfield = "";
    $wholeonly = "";
    $order = "";
    $ordtype = "";
  }

  $checkstr = "";
  if ($wholeonly) $checkstr = " checked";
  if ($ordtype == "asc") { $ordtypestr = "desc"; } else { $ordtypestr = "asc"; }
  $res = sql_select();
  $count = sql_getrecordcount();
  if ($count % $showrecs != 0) {
    $pagecount = intval($count / $showrecs) + 1;
  }
  else {
    $pagecount = intval($count / $showrecs);
  }
  $startrec = $showrecs * ($page - 1);
  if ($startrec < $count) {mysql_data_seek($res, $startrec);}
  $reccount = min($showrecs * $page, $count);
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr><td>Tabla: alumnos</td></tr>
<tr><td>Registros <?php echo $startrec + 1 ?> - <?php echo $reccount ?> de <?php echo $count ?></td></tr>
</table>
<hr size="1" noshade>
<form action="alumnosmuestra.php" method="post">
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><b>Filtrar por</b>&nbsp;</td>
<td><input type="text" name="filter" value="<?php echo $filter ?>"></td>
<td><select name="filter_field">
<option value="">Todos los Campos</option>
<option value="<?php echo "id_alumno" ?>"<?php if ($filterfield == "id_alumno") { echo "selected"; } ?>><?php echo htmlspecialchars("id_alumno") ?></option>
<option value="<?php echo "tipodoc" ?>"<?php if ($filterfield == "tipodoc") { echo "selected"; } ?>><?php echo htmlspecialchars("tipodoc") ?></option>
<option value="<?php echo "cedula" ?>"<?php if ($filterfield == "cedula") { echo "selected"; } ?>><?php echo htmlspecialchars("cedula") ?></option>
<option value="<?php echo "nacionalidad" ?>"<?php if ($filterfield == "nacionalidad") { echo "selected"; } ?>><?php echo htmlspecialchars("nacionalidad") ?></option>
<option value="<?php echo "fechanac" ?>"<?php if ($filterfield == "fechanac") { echo "selected"; } ?>><?php echo htmlspecialchars("fechanac") ?></option>
<option value="<?php echo "etnia" ?>"<?php if ($filterfield == "etnia") { echo "selected"; } ?>><?php echo htmlspecialchars("etnia") ?></option>
<option value="<?php echo "apellidos" ?>"<?php if ($filterfield == "apellidos") { echo "selected"; } ?>><?php echo htmlspecialchars("apellidos") ?></option>
<option value="<?php echo "nombres" ?>"<?php if ($filterfield == "nombres") { echo "selected"; } ?>><?php echo htmlspecialchars("nombres") ?></option>
<option value="<?php echo "genero" ?>"<?php if ($filterfield == "genero") { echo "selected"; } ?>><?php echo htmlspecialchars("genero") ?></option>
<option value="<?php echo "edocivil" ?>"<?php if ($filterfield == "edocivil") { echo "selected"; } ?>><?php echo htmlspecialchars("edocivil") ?></option>
<option value="<?php echo "direccion" ?>"<?php if ($filterfield == "direccion") { echo "selected"; } ?>><?php echo htmlspecialchars("direccion") ?></option>
<option value="<?php echo "telefonoh" ?>"<?php if ($filterfield == "telefonoh") { echo "selected"; } ?>><?php echo htmlspecialchars("telefonoh") ?></option>
<option value="<?php echo "telefonot" ?>"<?php if ($filterfield == "telefonot") { echo "selected"; } ?>><?php echo htmlspecialchars("telefonot") ?></option>
<option value="<?php echo "telefonoc" ?>"<?php if ($filterfield == "telefonoc") { echo "selected"; } ?>><?php echo htmlspecialchars("telefonoc") ?></option>
<option value="<?php echo "email" ?>"<?php if ($filterfield == "email") { echo "selected"; } ?>><?php echo htmlspecialchars("email") ?></option>
<option value="<?php echo "lugar" ?>"<?php if ($filterfield == "lugar") { echo "selected"; } ?>><?php echo htmlspecialchars("lugar") ?></option>
<option value="<?php echo "pais" ?>"<?php if ($filterfield == "pais") { echo "selected"; } ?>><?php echo htmlspecialchars("pais") ?></option>
<option value="<?php echo "estado" ?>"<?php if ($filterfield == "estado") { echo "selected"; } ?>><?php echo htmlspecialchars("estado") ?></option>
<option value="<?php echo "municipio" ?>"<?php if ($filterfield == "municipio") { echo "selected"; } ?>><?php echo htmlspecialchars("municipio") ?></option>
<option value="<?php echo "parroquia" ?>"<?php if ($filterfield == "parroquia") { echo "selected"; } ?>><?php echo htmlspecialchars("parroquia") ?></option>
<option value="<?php echo "nivelacad" ?>"<?php if ($filterfield == "nivelacad") { echo "selected"; } ?>><?php echo htmlspecialchars("nivelacad") ?></option>
<option value="<?php echo "gradoacad" ?>"<?php if ($filterfield == "gradoacad") { echo "selected"; } ?>><?php echo htmlspecialchars("gradoacad") ?></option>
<option value="<?php echo "condicion_res" ?>"<?php if ($filterfield == "condicion_res") { echo "selected"; } ?>><?php echo htmlspecialchars("condicion_res") ?></option>
<option value="<?php echo "fecha_ingreso" ?>"<?php if ($filterfield == "fecha_ingreso") { echo "selected"; } ?>><?php echo htmlspecialchars("fecha_ingreso") ?></option>
<option value="<?php echo "ultima_inscripcion" ?>"<?php if ($filterfield == "ultima_inscripcion") { echo "selected"; } ?>><?php echo htmlspecialchars("ultima_inscripcion") ?></option>
<option value="<?php echo "becado" ?>"<?php if ($filterfield == "becado") { echo "selected"; } ?>><?php echo htmlspecialchars("becado") ?></option>
<option value="<?php echo "privado_lib" ?>"<?php if ($filterfield == "privado_lib") { echo "selected"; } ?>><?php echo htmlspecialchars("privado_lib") ?></option>
<option value="<?php echo "idiomas" ?>"<?php if ($filterfield == "idiomas") { echo "selected"; } ?>><?php echo htmlspecialchars("idiomas") ?></option>
<option value="<?php echo "N1" ?>"<?php if ($filterfield == "N1") { echo "selected"; } ?>><?php echo htmlspecialchars("N1") ?></option>
<option value="<?php echo "N2" ?>"<?php if ($filterfield == "N2") { echo "selected"; } ?>><?php echo htmlspecialchars("N2") ?></option>
<option value="<?php echo "sede" ?>"<?php if ($filterfield == "sede") { echo "selected"; } ?>><?php echo htmlspecialchars("sede") ?></option>
<option value="<?php echo "discapacidad" ?>"<?php if ($filterfield == "discapacidad") { echo "selected"; } ?>><?php echo htmlspecialchars("discapacidad") ?></option>
</select></td>
<td><input type="checkbox" name="wholeonly"<?php echo $checkstr ?>>Palabra Completa</td>
</td></tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="action" value="Aplicar Filtro"></td>
<td><a href="alumnosmuestra.php?a=reset">Quitar Filtro</a></td>
</tr>
</table>
</form>
<hr size="1" noshade>
<?php showpagenav($page, $pagecount); ?>
<br>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="100%">
<tr>
<td class="hr">&nbsp;</td>
<td class="hr">&nbsp;</td>
<td class="hr">&nbsp;</td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "id_alumno" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("id_alumno") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "tipodoc" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("tipodoc") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "cedula" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("cedula") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "nacionalidad" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("nacionalidad") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "fechanac" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("fechanac") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "etnia" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("etnia") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "apellidos" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("apellidos") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "nombres" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("nombres") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "genero" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("genero") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "edocivil" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("edocivil") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "direccion" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("direccion") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "telefonoh" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("telefonoh") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "telefonot" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("telefonot") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "telefonoc" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("telefonoc") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "email" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("email") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "lugar" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("lugar") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "pais" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("pais") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "estado" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("estado") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "municipio" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("municipio") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "parroquia" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("parroquia") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "nivelacad" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("nivelacad") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "gradoacad" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("gradoacad") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "condicion_res" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("condicion_res") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "fecha_ingreso" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("fecha_ingreso") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "ultima_inscripcion" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("ultima_inscripcion") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "becado" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("becado") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "privado_lib" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("privado_lib") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "idiomas" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("idiomas") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "N1" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("N1") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "N2" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("N2") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "sede" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("sede") ?></a></td>
<td class="hr"><a class="hr" href="alumnosmuestra.php?order=<?php echo "discapacidad" ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars("discapacidad") ?></a></td>
</tr>
<?php
  for ($i = $startrec; $i < $reccount; $i++)
  {
    $row = mysql_fetch_assoc($res);
    $style = "dr";
    if ($i % 2 != 0) {
      $style = "sr";
    }
?>
<tr>
<td class="<?php echo $style ?>"><a href="alumnosmuestra.php?a=view&recid=<?php echo $i ?>">Ver</a></td>
<td class="<?php echo $style ?>"><a href="alumnosmuestra.php?a=edit&recid=<?php echo $i ?>">Editar</a></td>
<td class="<?php echo $style ?>"><a href="alumnosmuestra.php?a=del&recid=<?php echo $i ?>">Borrar</a></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["id_alumno"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["tipodoc"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["cedula"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["nacionalidad"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["fechanac"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["etnia"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["apellidos"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["nombres"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["genero"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["edocivil"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["direccion"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["telefonoh"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["telefonot"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["telefonoc"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["email"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["lugar"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["pais"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["estado"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["municipio"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["parroquia"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["nivelacad"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["gradoacad"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["condicion_res"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["fecha_ingreso"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["ultima_inscripcion"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["becado"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["privado_lib"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["idiomas"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["N1"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["N2"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["sede"]) ?></td>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row["discapacidad"]) ?></td>
</tr>
<?php
  }
  mysql_free_result($res);
?>
</table>
<br>
<?php } ?>

<?php function showrow($row, $recid)
  {
?>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="50%">
<tr>
<td class="hr"><?php echo htmlspecialchars("id_alumno")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["id_alumno"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("tipodoc")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["tipodoc"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("cedula")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["cedula"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("nacionalidad")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["nacionalidad"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("fechanac")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["fechanac"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("etnia")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["etnia"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("apellidos")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["apellidos"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("nombres")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["nombres"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("genero")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["genero"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("edocivil")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["edocivil"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("direccion")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["direccion"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("telefonoh")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["telefonoh"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("telefonot")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["telefonot"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("telefonoc")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["telefonoc"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("email")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["email"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("lugar")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["lugar"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("pais")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["pais"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("estado")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["estado"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("municipio")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["municipio"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("parroquia")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["parroquia"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("nivelacad")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["nivelacad"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("gradoacad")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["gradoacad"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("condicion_res")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["condicion_res"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("fecha_ingreso")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["fecha_ingreso"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("ultima_inscripcion")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["ultima_inscripcion"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("becado")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["becado"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("privado_lib")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["privado_lib"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("idiomas")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["idiomas"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("N1")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["N1"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("N2")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["N2"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("sede")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["sede"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("discapacidad")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["discapacidad"]) ?></td>
</tr>
</table>
<?php } ?>

<?php function showroweditor($row, $iseditmode)
  {
  global $conn;
?>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="50%">
<tr>
<td class="hr"><?php echo htmlspecialchars("id_alumno")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="id_alumno" value="<?php echo str_replace('"', '&quot;', trim($row["id_alumno"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("tipodoc")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="tipodoc" maxlength="9" value="<?php echo str_replace('"', '&quot;', trim($row["tipodoc"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("cedula")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="cedula" maxlength="12" value="<?php echo str_replace('"', '&quot;', trim($row["cedula"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("nacionalidad")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="nacionalidad" maxlength="1" value="<?php echo str_replace('"', '&quot;', trim($row["nacionalidad"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("fechanac")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="fechanac" value="<?php echo str_replace('"', '&quot;', trim($row["fechanac"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("etnia")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="etnia" maxlength="2" value="<?php echo str_replace('"', '&quot;', trim($row["etnia"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("apellidos")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="apellidos" maxlength="50" value="<?php echo str_replace('"', '&quot;', trim($row["apellidos"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("nombres")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="nombres" maxlength="50" value="<?php echo str_replace('"', '&quot;', trim($row["nombres"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("genero")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="genero" maxlength="1" value="<?php echo str_replace('"', '&quot;', trim($row["genero"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("edocivil")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="edocivil" maxlength="13" value="<?php echo str_replace('"', '&quot;', trim($row["edocivil"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("direccion")."&nbsp;" ?></td>
<td class="dr"><textarea cols="35" rows="4" name="direccion" maxlength="160"><?php echo str_replace('"', '&quot;', trim($row["direccion"])) ?></textarea></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("telefonoh")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="telefonoh" maxlength="20" value="<?php echo str_replace('"', '&quot;', trim($row["telefonoh"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("telefonot")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="telefonot" maxlength="15" value="<?php echo str_replace('"', '&quot;', trim($row["telefonot"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("telefonoc")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="telefonoc" maxlength="15" value="<?php echo str_replace('"', '&quot;', trim($row["telefonoc"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("email")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="email" maxlength="50" value="<?php echo str_replace('"', '&quot;', trim($row["email"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("lugar")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="lugar" maxlength="40" value="<?php echo str_replace('"', '&quot;', trim($row["lugar"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("pais")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="pais" maxlength="3" value="<?php echo str_replace('"', '&quot;', trim($row["pais"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("estado")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="estado" maxlength="2" value="<?php echo str_replace('"', '&quot;', trim($row["estado"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("municipio")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="municipio" maxlength="4" value="<?php echo str_replace('"', '&quot;', trim($row["municipio"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("parroquia")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="parroquia" maxlength="6" value="<?php echo str_replace('"', '&quot;', trim($row["parroquia"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("nivelacad")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="nivelacad" maxlength="10" value="<?php echo str_replace('"', '&quot;', trim($row["nivelacad"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("gradoacad")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="gradoacad" maxlength="1" value="<?php echo str_replace('"', '&quot;', trim($row["gradoacad"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("condicion_res")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="condicion_res" maxlength="10" value="<?php echo str_replace('"', '&quot;', trim($row["condicion_res"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("fecha_ingreso")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="fecha_ingreso" value="<?php echo str_replace('"', '&quot;', trim($row["fecha_ingreso"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("ultima_inscripcion")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="ultima_inscripcion" value="<?php echo str_replace('"', '&quot;', trim($row["ultima_inscripcion"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("becado")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="becado" maxlength="9" value="<?php echo str_replace('"', '&quot;', trim($row["becado"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("privado_lib")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="privado_lib" maxlength="9" value="<?php echo str_replace('"', '&quot;', trim($row["privado_lib"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("idiomas")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="idiomas" maxlength="2" value="<?php echo str_replace('"', '&quot;', trim($row["idiomas"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("N1")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="N1" maxlength="50" value="<?php echo str_replace('"', '&quot;', trim($row["N1"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("N2")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="N2" maxlength="50" value="<?php echo str_replace('"', '&quot;', trim($row["N2"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("sede")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="sede" maxlength="2" value="<?php echo str_replace('"', '&quot;', trim($row["sede"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("discapacidad")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="discapacidad" maxlength="2" value="<?php echo str_replace('"', '&quot;', trim($row["discapacidad"])) ?>"></td>
</tr>
</table>
<?php } ?>

<?php function showpagenav($page, $pagecount)
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="alumnosmuestra.php?a=add">Agregar </a>&nbsp;</td>
<?php if ($page > 1) { ?>
<td><a href="alumnosmuestra.php?page=<?php echo $page - 1 ?>">&lt;&lt;&nbsp;Anterior</a>&nbsp;</td>
<?php } ?>
<?php
  global $pagerange;

  if ($pagecount > 1) {

  if ($pagecount % $pagerange != 0) {
    $rangecount = intval($pagecount / $pagerange) + 1;
  }
  else {
    $rangecount = intval($pagecount / $pagerange);
  }
  for ($i = 1; $i < $rangecount + 1; $i++) {
    $startpage = (($i - 1) * $pagerange) + 1;
    $count = min($i * $pagerange, $pagecount);

    if ((($page >= $startpage) && ($page <= ($i * $pagerange)))) {
      for ($j = $startpage; $j < $count + 1; $j++) {
        if ($j == $page) {
?>
<td><b><?php echo $j ?></b></td>
<?php } else { ?>
<td><a href="alumnosmuestra.php?page=<?php echo $j ?>"><?php echo $j ?></a></td>
<?php } } } else { ?>
<td><a href="alumnosmuestra.php?page=<?php echo $startpage ?>"><?php echo $startpage ."..." .$count ?></a></td>
<?php } } } ?>
<?php if ($page < $pagecount) { ?>
<td>&nbsp;<a href="alumnosmuestra.php?page=<?php echo $page + 1 ?>">Siguiente&nbsp;&gt;&gt;</a>&nbsp;</td>
<?php } ?>
</tr>
</table>
<?php } ?>

<?php function showrecnav($a, $recid, $count)
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="alumnosmuestra.php">Regresar</a></td>
<?php if ($recid > 0) { ?>
<td><a href="alumnosmuestra.php?a=<?php echo $a ?>&recid=<?php echo $recid - 1 ?>">Registro Anterior</a></td>
<?php } if ($recid < $count - 1) { ?>
<td><a href="alumnosmuestra.php?a=<?php echo $a ?>&recid=<?php echo $recid + 1 ?>">Siguiente Registro</a></td>
<?php } ?>
</tr>
</table>
<hr size="1" noshade>
<?php } ?>

<?php function addrec()
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="alumnosmuestra.php">Regresar</a></td>
</tr>
</table>
<hr size="1" noshade>
<form enctype="multipart/form-data" action="alumnosmuestra.php" method="post">
<p><input type="hidden" name="sql" value="insert"></p>
<?php
$row = array(
  "id_alumno" => "",
  "tipodoc" => "",
  "cedula" => "",
  "nacionalidad" => "",
  "fechanac" => "",
  "etnia" => "",
  "apellidos" => "",
  "nombres" => "",
  "genero" => "",
  "edocivil" => "",
  "direccion" => "",
  "telefonoh" => "",
  "telefonot" => "",
  "telefonoc" => "",
  "email" => "",
  "lugar" => "",
  "pais" => "",
  "estado" => "",
  "municipio" => "",
  "parroquia" => "",
  "nivelacad" => "",
  "gradoacad" => "",
  "condicion_res" => "",
  "fecha_ingreso" => "",
  "ultima_inscripcion" => "",
  "becado" => "",
  "privado_lib" => "",
  "idiomas" => "",
  "N1" => "",
  "N2" => "",
  "sede" => "",
  "discapacidad" => "");
showroweditor($row, false);
?>
<p><input type="submit" name="action" value="Guardar"></p>
</form>
<?php } ?>

<?php function viewrec($recid)
{
  $res = sql_select();
  $count = sql_getrecordcount();
  mysql_data_seek($res, $recid);
  $row = mysql_fetch_assoc($res);
  showrecnav("view", $recid, $count);
?>
<br>
<?php showrow($row, $recid) ?>
<br>
<hr size="1" noshade>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="alumnosmuestra.php?a=add">Agregar </a></td>
<td><a href="alumnosmuestra.php?a=edit&recid=<?php echo $recid ?>">Editar </a></td>
<td><a href="alumnosmuestra.php?a=del&recid=<?php echo $recid ?>">Borrar </a></td>
</tr>
</table>
<?php
  mysql_free_result($res);
} ?>

<?php function editrec($recid)
{
  $res = sql_select();
  $count = sql_getrecordcount();
  mysql_data_seek($res, $recid);
  $row = mysql_fetch_assoc($res);
  showrecnav("edit", $recid, $count);
?>
<br>
<form enctype="multipart/form-data" action="alumnosmuestra.php" method="post">
<input type="hidden" name="sql" value="update">
<input type="hidden" name="xid_alumno" value="<?php echo $row["id_alumno"] ?>">
<?php showroweditor($row, true); ?>
<p><input type="submit" name="action" value="Guardar"></p>
</form>
<?php
  mysql_free_result($res);
} ?>

<?php function deleterec($recid)
{
  $res = sql_select();
  $count = sql_getrecordcount();
  mysql_data_seek($res, $recid);
  $row = mysql_fetch_assoc($res);
  showrecnav("del", $recid, $count);
?>
<br>
<form action="alumnosmuestra.php" method="post">
<input type="hidden" name="sql" value="delete">
<input type="hidden" name="xid_alumno" value="<?php echo $row["id_alumno"] ?>">
<?php showrow($row, $recid) ?>
<p><input type="submit" name="action" value="Confirmar"></p>
</form>
<?php
  mysql_free_result($res);
} ?>

<?php function connect()
{
  $conn = mysql_connect("localhost", "ceula_sadce_admi", "j7BnJdCGzyQBGcud");
  mysql_select_db("ceulac_sadce");
  return $conn;
}

function sqlvalue($val, $quote)
{
  if ($quote)
    $tmp = sqlstr($val);
  else
    $tmp = $val;
  if ($tmp == "")
    $tmp = "NULL";
  elseif ($quote)
    $tmp = "'".$tmp."'";
  return $tmp;
}

function sqlstr($val)
{
  return str_replace("'", "''", $val);
}

function sql_select()
{
  global $conn;
  global $order;
  global $ordtype;
  global $filter;
  global $filterfield;
  global $wholeonly;

  $filterstr = sqlstr($filter);
  if (!$wholeonly && isset($wholeonly) && $filterstr!='') $filterstr = "%" .$filterstr ."%";
  $sql = "SELECT `id_alumno`, `tipodoc`, `cedula`, `nacionalidad`, `fechanac`, `etnia`, `apellidos`, `nombres`, `genero`, `edocivil`, `direccion`, `telefonoh`, `telefonot`, `telefonoc`, `email`, `lugar`, `pais`, `estado`, `municipio`, `parroquia`, `nivelacad`, `gradoacad`, `condicion_res`, `fecha_ingreso`, `ultima_inscripcion`, `becado`, `privado_lib`, `idiomas`, N1, N2, `sede`, `discapacidad` FROM `alumnos`";
  if (isset($filterstr) && $filterstr!='' && isset($filterfield) && $filterfield!='') {
    $sql .= " where " .sqlstr($filterfield) ." like '" .$filterstr ."'";
  } elseif (isset($filterstr) && $filterstr!='') {
    $sql .= " where (`id_alumno` like '" .$filterstr ."') or (`tipodoc` like '" .$filterstr ."') or (`cedula` like '" .$filterstr ."') or (`nacionalidad` like '" .$filterstr ."') or (`fechanac` like '" .$filterstr ."') or (`etnia` like '" .$filterstr ."') or (`apellidos` like '" .$filterstr ."') or (`nombres` like '" .$filterstr ."') or (`genero` like '" .$filterstr ."') or (`edocivil` like '" .$filterstr ."') or (`direccion` like '" .$filterstr ."') or (`telefonoh` like '" .$filterstr ."') or (`telefonot` like '" .$filterstr ."') or (`telefonoc` like '" .$filterstr ."') or (`email` like '" .$filterstr ."') or (`lugar` like '" .$filterstr ."') or (`pais` like '" .$filterstr ."') or (`estado` like '" .$filterstr ."') or (`municipio` like '" .$filterstr ."') or (`parroquia` like '" .$filterstr ."') or (`nivelacad` like '" .$filterstr ."') or (`gradoacad` like '" .$filterstr ."') or (`condicion_res` like '" .$filterstr ."') or (`fecha_ingreso` like '" .$filterstr ."') or (`ultima_inscripcion` like '" .$filterstr ."') or (`becado` like '" .$filterstr ."') or (`privado_lib` like '" .$filterstr ."') or (`idiomas` like '" .$filterstr ."') or (N1 like '" .$filterstr ."') or (N2 like '" .$filterstr ."') or (`sede` like '" .$filterstr ."') or (`discapacidad` like '" .$filterstr ."')";
  }
  if (isset($order) && $order!='') $sql .= " order by `" .sqlstr($order) ."`";
  if (isset($ordtype) && $ordtype!='') $sql .= " " .sqlstr($ordtype);
  $res = mysql_query($sql, $conn) or die(mysql_error());
  return $res;
}

function sql_getrecordcount()
{
  global $conn;
  global $order;
  global $ordtype;
  global $filter;
  global $filterfield;
  global $wholeonly;

  $filterstr = sqlstr($filter);
  if (!$wholeonly && isset($wholeonly) && $filterstr!='') $filterstr = "%" .$filterstr ."%";
  $sql = "SELECT COUNT(*) FROM `alumnos`";
  if (isset($filterstr) && $filterstr!='' && isset($filterfield) && $filterfield!='') {
    $sql .= " where " .sqlstr($filterfield) ." like '" .$filterstr ."'";
  } elseif (isset($filterstr) && $filterstr!='') {
    $sql .= " where (`id_alumno` like '" .$filterstr ."') or (`tipodoc` like '" .$filterstr ."') or (`cedula` like '" .$filterstr ."') or (`nacionalidad` like '" .$filterstr ."') or (`fechanac` like '" .$filterstr ."') or (`etnia` like '" .$filterstr ."') or (`apellidos` like '" .$filterstr ."') or (`nombres` like '" .$filterstr ."') or (`genero` like '" .$filterstr ."') or (`edocivil` like '" .$filterstr ."') or (`direccion` like '" .$filterstr ."') or (`telefonoh` like '" .$filterstr ."') or (`telefonot` like '" .$filterstr ."') or (`telefonoc` like '" .$filterstr ."') or (`email` like '" .$filterstr ."') or (`lugar` like '" .$filterstr ."') or (`pais` like '" .$filterstr ."') or (`estado` like '" .$filterstr ."') or (`municipio` like '" .$filterstr ."') or (`parroquia` like '" .$filterstr ."') or (`nivelacad` like '" .$filterstr ."') or (`gradoacad` like '" .$filterstr ."') or (`condicion_res` like '" .$filterstr ."') or (`fecha_ingreso` like '" .$filterstr ."') or (`ultima_inscripcion` like '" .$filterstr ."') or (`becado` like '" .$filterstr ."') or (`privado_lib` like '" .$filterstr ."') or (`idiomas` like '" .$filterstr ."') or (N1 like '" .$filterstr ."') or (N2 like '" .$filterstr ."') or (`sede` like '" .$filterstr ."') or (`discapacidad` like '" .$filterstr ."')";
  }
  $res = mysql_query($sql, $conn) or die(mysql_error());
  $row = mysql_fetch_assoc($res);
  reset($row);
  return current($row);
}

function sql_insert()
{
  global $conn;
  global $_POST;

  $sql = "insert into `alumnos` (`id_alumno`, `tipodoc`, `cedula`, `nacionalidad`, `fechanac`, `etnia`, `apellidos`, `nombres`, `genero`, `edocivil`, `direccion`, `telefonoh`, `telefonot`, `telefonoc`, `email`, `lugar`, `pais`, `estado`, `municipio`, `parroquia`, `nivelacad`, `gradoacad`, `condicion_res`, `fecha_ingreso`, `ultima_inscripcion`, `becado`, `privado_lib`, `idiomas`, N1, N2, `sede`, `discapacidad`) values (" .sqlvalue(@$_POST["id_alumno"], false).", " .sqlvalue(@$_POST["tipodoc"], true).", " .sqlvalue(@$_POST["cedula"], true).", " .sqlvalue(@$_POST["nacionalidad"], true).", " .sqlvalue(@$_POST["fechanac"], true).", " .sqlvalue(@$_POST["etnia"], true).", " .sqlvalue(@$_POST["apellidos"], true).", " .sqlvalue(@$_POST["nombres"], true).", " .sqlvalue(@$_POST["genero"], true).", " .sqlvalue(@$_POST["edocivil"], true).", " .sqlvalue(@$_POST["direccion"], true).", " .sqlvalue(@$_POST["telefonoh"], true).", " .sqlvalue(@$_POST["telefonot"], true).", " .sqlvalue(@$_POST["telefonoc"], true).", " .sqlvalue(@$_POST["email"], true).", " .sqlvalue(@$_POST["lugar"], true).", " .sqlvalue(@$_POST["pais"], true).", " .sqlvalue(@$_POST["estado"], true).", " .sqlvalue(@$_POST["municipio"], true).", " .sqlvalue(@$_POST["parroquia"], true).", " .sqlvalue(@$_POST["nivelacad"], true).", " .sqlvalue(@$_POST["gradoacad"], true).", " .sqlvalue(@$_POST["condicion_res"], true).", " .sqlvalue(@$_POST["fecha_ingreso"], true).", " .sqlvalue(@$_POST["ultima_inscripcion"], true).", " .sqlvalue(@$_POST["becado"], true).", " .sqlvalue(@$_POST["privado_lib"], true).", " .sqlvalue(@$_POST["idiomas"], true).", " .sqlvalue(@$_POST["N1"], true).", " .sqlvalue(@$_POST["N2"], true).", " .sqlvalue(@$_POST["sede"], true).", " .sqlvalue(@$_POST["discapacidad"], true).")";
  mysql_query($sql, $conn) or die(mysql_error());
}

function sql_update()
{
  global $conn;
  global $_POST;

  $sql = "update `alumnos` set `id_alumno`=" .sqlvalue(@$_POST["id_alumno"], false).", `tipodoc`=" .sqlvalue(@$_POST["tipodoc"], true).", `cedula`=" .sqlvalue(@$_POST["cedula"], true).", `nacionalidad`=" .sqlvalue(@$_POST["nacionalidad"], true).", `fechanac`=" .sqlvalue(@$_POST["fechanac"], true).", `etnia`=" .sqlvalue(@$_POST["etnia"], true).", `apellidos`=" .sqlvalue(@$_POST["apellidos"], true).", `nombres`=" .sqlvalue(@$_POST["nombres"], true).", `genero`=" .sqlvalue(@$_POST["genero"], true).", `edocivil`=" .sqlvalue(@$_POST["edocivil"], true).", `direccion`=" .sqlvalue(@$_POST["direccion"], true).", `telefonoh`=" .sqlvalue(@$_POST["telefonoh"], true).", `telefonot`=" .sqlvalue(@$_POST["telefonot"], true).", `telefonoc`=" .sqlvalue(@$_POST["telefonoc"], true).", `email`=" .sqlvalue(@$_POST["email"], true).", `lugar`=" .sqlvalue(@$_POST["lugar"], true).", `pais`=" .sqlvalue(@$_POST["pais"], true).", `estado`=" .sqlvalue(@$_POST["estado"], true).", `municipio`=" .sqlvalue(@$_POST["municipio"], true).", `parroquia`=" .sqlvalue(@$_POST["parroquia"], true).", `nivelacad`=" .sqlvalue(@$_POST["nivelacad"], true).", `gradoacad`=" .sqlvalue(@$_POST["gradoacad"], true).", `condicion_res`=" .sqlvalue(@$_POST["condicion_res"], true).", `fecha_ingreso`=" .sqlvalue(@$_POST["fecha_ingreso"], true).", `ultima_inscripcion`=" .sqlvalue(@$_POST["ultima_inscripcion"], true).", `becado`=" .sqlvalue(@$_POST["becado"], true).", `privado_lib`=" .sqlvalue(@$_POST["privado_lib"], true).", `idiomas`=" .sqlvalue(@$_POST["idiomas"], true).", N1=" .sqlvalue(@$_POST["N1"], true).", N2=" .sqlvalue(@$_POST["N2"], true).", `sede`=" .sqlvalue(@$_POST["sede"], true).", `discapacidad`=" .sqlvalue(@$_POST["discapacidad"], true) ." where " .primarykeycondition();
  mysql_query($sql, $conn) or die(mysql_error());
}

function sql_delete()
{
  global $conn;

  $sql = "delete from `alumnos` where " .primarykeycondition();
  mysql_query($sql, $conn) or die(mysql_error());
}
function primarykeycondition()
{
  global $_POST;
  $pk = "";
  $pk .= "(`id_alumno`";
  if (@$_POST["xid_alumno"] == "") {
    $pk .= " IS NULL";
  }else{
  $pk .= " = " .sqlvalue(@$_POST["xid_alumno"], false);
  };
  $pk .= ")";
  return $pk;
}
 ?>
