Foros del Web » Programando para Internet » PHP »

seleccionar una tabla para cargar su contenido

Estas en el tema de seleccionar una tabla para cargar su contenido en el foro de PHP en Foros del Web. Hola a todos. Pues mi problema es el siguiente. tengo una pagina donde cargo los datos de una tabla que previamente selecciono. Hasta ahí todo ...
  #1 (permalink)  
Antiguo 06/10/2010, 12:25
 
Fecha de Ingreso: marzo-2010
Mensajes: 61
Antigüedad: 14 años, 1 mes
Puntos: 1
seleccionar una tabla para cargar su contenido

Hola a todos. Pues mi problema es el siguiente. tengo una pagina donde cargo los datos de una tabla que previamente selecciono. Hasta ahí todo bien pq lo había hacia mediante un formulario que en una pagina previa y desde la pagina donde cargo la tabla leía los datos del formulario mediante $_POST y la cargaba.

Mi problema viene ahora cuando quiero seleccionar en la misma pagina mediante un menú desplegable la tabla para cargarla justo abajo de donde la selecciono. No se como hacerlo en la misma pagina.

A ver si alguien me echa una mano..

Muchas gracias!!!
  #2 (permalink)  
Antiguo 06/10/2010, 13:43
Avatar de carmagedon  
Fecha de Ingreso: junio-2005
Ubicación: Argentina
Mensajes: 794
Antigüedad: 18 años, 10 meses
Puntos: 23
Respuesta: seleccionar una tabla para cargar su contenido

Hola,

Sería un estilo de expand? Es decir, se expande otra tabla o lo que fuese, debajo de la seleccionada?
Si es así, mi solución es hacerlo con javascript, que ya tiene el insertBefore para los childs, es decir, obtenés el ID del elemento, y lo que hacés es insertar esos registros de la tabla en el lugar selecciondo pero antes del siguiente.

Quizás te suene difícil si es que no trabajaste con javascript, pero para que veas, leete ésto http://blog.outbook.es/desarrollo-we...-y-appendchild que quizás te resulte más fácil realizarlo...

Con PHP ahora algo rápido y fácil no se me ocurre, pero bueno, será cuestión que si tenes que realizarlo con php, te ayude algún experto en el tema.

Suerte!
__________________
Freelance - Aplicaciones Web
  #3 (permalink)  
Antiguo 07/10/2010, 08:40
Avatar de blonder413  
Fecha de Ingreso: octubre-2010
Mensajes: 58
Antigüedad: 13 años, 6 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>
  #4 (permalink)  
Antiguo 07/10/2010, 12:14
 
Fecha de Ingreso: marzo-2010
Mensajes: 61
Antigüedad: 14 años, 1 mes
Puntos: 1
Respuesta: seleccionar una tabla para cargar su contenido

Cita:
Iniciado por blonder413 Ver Mensaje
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>

hola.. me he puesto a hacerlo de esta manera... y me da un error en :

while ($reg=mysql_fetch_array($res)) y no encuentro pq.. voy a pegar el codigo a ver si veis algo..



<?php
require_once("conex.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="+ced ula;
}
}

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="ordena" action="ordenlista.php" method="get">
<select name="tabla">
<option value="ninguna" selected="selected">SELECCION</option>
<option value="associazioni_imprese">Associazioni imprese</option>
<option value="banche">Banche</option>
<option value="confidi">Confidi</option>
<option value="credito_alle_imprese">Credito alle imprese</option>
<option value="crisi_d_impresa"> Crisi d'impresa</option>
<option value="derivati">Derivati</option>
<option value="private_equity">Private Equity</option>
<option value="settori_e_distretti">Settori e Distretti</option>
<option value="turnaround">Turnaround</option>
<option value="cosa_dicono">Cosa dicono</option>
</select>&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="ordena" 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
$link=Conectarse();
$sql="SELECT id,titulo,ruta FROM ".$_GET["ordena"]."";
$res=mysql_query($sql,$link);
while ($reg=mysql_fetch_array($res))
{
?>
<tr class="registros">
<td valign="middle" align="left" width="70"><?php echo $reg["id"]; ?> </td>
<td valign="middle" align="left" width="170"><?php echo $reg["titulo"]; ?> </td>
<td valign="middle" align="left" width="120"><?php echo $reg["ruta"]; ?> </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($link); //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>




muchas gracias!!

Etiquetas: contenido, seleccionar, tablas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:41.