Ver Mensaje Individual
  #3 (permalink)  
Antiguo 26/05/2011, 14:59
Avatar de evolutionrgm
evolutionrgm
 
Fecha de Ingreso: mayo-2011
Mensajes: 108
Antigüedad: 13 años, 9 meses
Puntos: 5
Información Respuesta: datagrid como crearlo

yo lo mas parecido a un data grid lo genero de esta forma

Cita:
<form method="post" action="mantencion_noticias.php">
<table border="0" width="100%">
<tr>
<td width="100%" colspan="2" bordercolor="#FFFF00"><b> Buscar Noticias</b></td>
</tr>
<tr>
<td width="30%">
<p align="center">Buscar : </td>
<td width="70%"><input type="text" name="buscar" size="32"></td>
</tr>
<tr>
<td width="30%" height="25">
<p align="center"></td>
<td width="70%" height="25"><input type="submit" value="Enviar" name="envio" /></td>
</tr>
<tr>
<td width="30%" height="25">
<p align="center">: </td>
<td width="70%" height="25">&nbsp;</td>
</tr>
<tr>
<td width="30%"></td>
<td width="70%">&nbsp;</td>
</tr>
</table>

</form>
luego hago la grilla segun la consulta
Cita:
<?php
}
else
{


//listamos las noticias
$sql = "select * from news ";

if (isset($_POST['buscar']) and $_POST['buscar'] != "")
{
$buscar = $_POST['buscar'];
//echo "HOLAAA";
$sql.="where id_news = $buscar";
}
elseif (isset($_POST['tipo']) and $_POST['tipo'] != "TODOS")
{
//echo "CHAOO";
$tipo = $_POST['tipo'];
$sql.="where tipo = $tipo";

}
//ordeno
if (isset($_POST["orden"]))//!= ''
$orden = $_POST["orden"];
{
//$sql.=" order by $orden ";
}
$result = mysql_query($sql);
if (mysql_error())
{
echo " ERROR al agregar el tipo de Contacto - ".
mysql_errno() .":". mysql_error()."<br>";
}

//calculo la cantidad de resultados
$cant_resultados = mysql_num_rows ($result);

if ($cant_resultados >=1)
{
//muestro los resultados
echo " se han encontrado $cant_resultados resultados <br>";

?>

<?php

while ($myrow = mysql_fetch_array($result))
{
//armo link para editar
$leditar ="enoticias.php?id_news=$myrow[id_news]";
$lborrar ="bnoticias.php?id_news=$myrow[id_news]";
?>
<table border="1" width="100%" cellpadding="4" cellspacing="0">
<tr>
<td width="100%" bgcolor="#FFCC00"><strong>Codigo</strong><b><?php echo $myrow['id_news'];?> <strong>Titulo</strong>,<?php echo $myrow['titulo'];?></td>
</tr>
<tr>
<td width="100%">Fecha : <?php echo $myrow['fecha'];?></td>
</tr>
<tr>
<td width="100%">Tipo de Noticia : <?php echo $myrow['tipo'];?></td>
</tr>
<td width="100%">Noticia : <?php echo $myrow['noticia'];?></td>
</tr>
<tr>
<td width="100%"><a href="<?php echo $leditar; ?>">Editar </a>&nbsp;&nbsp;&nbsp; <a href="<?php echo $lborrar;?> " >Borrar </a></td>
</tr>
</table>

<?php