Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/10/2010, 08:40
Avatar de blonder413
blonder413
 
Fecha de Ingreso: octubre-2010
Mensajes: 58
Antigüedad: 13 años, 7 meses
Puntos: 0
Información Respuesta: seleccionar una tabla para cargar su contenido

yo hago esto para ordenar una tabla, pero bien podrian cambiarse los valores y la consulta para elegir otra

Código:
<?php
require_once("conexion.php");
?>
<html>
<head>
<title>Ingreso de Empleados</title>
<style type="text/css">
<!--
.Estilo1 {
	font-size: 36px;
	font-weight: bold;
	color: #669900;
}
.Estilo2 {font-size: 36px; font-weight: bold; color: #0000CC; }
.Estilo3 {
	font-size: 18px;
	font-weight: bold;
	color: #0000CC;
}
.Estilo5 {font-size: 18px; font-weight: bold; color: #669900; }
.Estilo6 {font-size: 24px}
-->
</style>

<style type="text/css">
	.encabezado{ background-color:#666666; color:#FFFFFF; font-weight:bold}
	.registros{ background-color:#f0f0f0}
</style>
<script language="javascript" type="text/javascript">
	function eliminar(cedula)
	{
		if (confirm("Realmente desea eliminar el registro?"))
		{
			window.location="eliminarempleado.php?cedula="+cedula;
		}
	}
	
	function defaul_combo(){
	<?php
		if(isset($_GET["ordena"])){
	?>
			document.orden.ordena.tabindex=".$_GET["ordena"].";
	<?php
		}else{
	?>
			document.orden.ordena.tabindex="cedula";
	<?php
		}
	?>
	}
	
</script>


</head>

<body>
<table width="715" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td width="715" height="124" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="217" height="124" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="217" height="124" valign="top"><img src="imagenes/logo.jpg" width="178" height="106"></td>
          </tr>
        </table>        </td>
        <td width="498" valign="top"><p align="center" class="Estilo2">Control </p>
          <p align="center" class="Estilo1">Material de Proteccion </p></td>
      </tr>
    </table>    </td>
  </tr>

<td height="171" valign="top">
<table width="700" align="center">
<tr>
<td valign="top" align="center" width="700" colspan="5">
<h3>Listado de empleados</h3>
</td>
</tr>
<tr>
<td valign="top" align="center" width="700" colspan="5">
	<form name="orden" action="ordenlista.php" method="get">
		<select name="ordena" title="Seleccione el criterio por el que desea ordenar">
			<option value="cedula">C&eacute;dula</option>
			<option value="nombre">Nombre</option>
			<option value="apellido1">Apellidos</option>
			<option value="fechaingreso">Fecha de ingreso</option>
		</select>&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="submit" value="Ordenar" title="Clic para Ordenar">
	</form>
</td>

</tr>

<tr class="encabezado">
<td valign="middle" align="center" width="70">Cedula</td>
<td valign="middle" align="center" width="170">Nombres</td>
<td valign="middle" align="center" width="120">Primer Apellido</td>
<td valign="middle" align="center" width="120">Segundo Apellido</td>
<td valign="middle" align="center" width="120">Fecha de Ingreso</td>
<td valign="middle" align="center" width="25">&nbsp;</td>
<td valign="middle" align="center" width="25">&nbsp;</td>
</tr>

<?php
$sql="SELECT * FROM empleado ORDER BY ".$_GET["ordena"]."";
$res=mysql_query($sql,$con);
while ($reg=mysql_fetch_array($res))
{
?>
<tr class="registros">
<td valign="middle" align="left" width="70"><?php echo $reg["cedula"]; ?> </td>
<td valign="middle" align="left" width="170"><?php echo $reg["nombre"]; ?> </td>
<td valign="middle" align="left" width="120"><?php echo $reg["apellido1"]; ?> </td>
<td valign="middle" align="left" width="120"><?php echo $reg["apellido2"]; ?> </td>
<td valign="middle" align="left" width="120"><?php echo $reg["fechaingreso"]; ?> </td>
<td valign="middle" align="left" width="25">
<a href="modificarempleado.php?cedula=<?php echo $reg["cedula"];?>" title="Modificar"><img src="ima/editar.png" border="0"></a>
</td>
<td valign="top" align="center" width="25">
<a href="javascript:void(0)" title="Eliminar" onClick="eliminar('<?php echo $reg["cedula"];?>')"><img src="ima/eliminar.png" border="0"></a>
</td>
</tr>
<?php
}	//cierre mysql_fetch_array
mysql_close($con);	//cierra la conexión a la base de datos
?>
<tr>
<td valign="top" align="right" width="700" colspan="5">
  <div align="center"><a href="index.html" title="Regresar"><img src="ima/regresar.png" width="103" height="44" border="0"></a>
    <a href="agregar.php" title="Agregar Empelados"><img src="ima/add48x48.png" border="0"></a></div></td>
</tr>

</table>
</body>
</html>