hola creo que esto es mas facil son datos de una base de datos mostrados en una tabla php fasilmente con un while
Código PHP:
$dbhost='localhost'; // Servidor
$dbusername='daniel'; // Nombre de usuario
$dbuserpass=''; // Contraseña
$dbname='punto'; // Nombre de la base de datos
$link=mysql_connect($dbhost,$dbusername,$dbuserpass);
mysql_select_db($dbname)or die('no se puede seleccionar la base de datos');
Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns2="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Punto de venta HDCR</title>
<link rel="stylesheet" type="text/css" href="stylemedic.css" media="screen" />
</head>
<body>
<div id="main_content">
<div id="iframe2">
[PHP]
<?
$resultado=mysql_query("SELECT * FROM producto",$link);
echo"
<table border='0'id='mi_tabla'>
<thead>
<tr> <td colspan='8'> Buscar <input id='filtrar' type='text' /></td><td colspan='5'><button onclick='salir(this)'accesskey='p'type='submit'>Salir</button></td></tr>
<tr>
<th><></th>
<th>CODIGO</th>
<th>DESCRIPCION</th>
<th>COSTO</th>
<th>VENTA</th>
<th>EXISTENCIAS</th>
<th>DIA</th>
<th>MES</th>
<th>Año</th>
</tr>
</thead>";
echo "<tbody>";
//ojo aqui esta el bucle que mustra los datos
while ($campo= mysql_fetch_row($resultado)){
$fecha=explode ("-",$campo[7]);
echo"<tr style='cursor:pointer' class='desmarcado' onclick='muestra(this)' >";
echo"<td>".$campo[1]."</td>";
echo"<td>".$campo[2]."</td>";
echo"<td>".$campo[3]."</td>";
echo"<td>".$campo[4]."</td>";
echo"<td>".$campo[5]."</td>";
echo"<td>".$campo[6]."</td>";
echo"<td>".$fecha[2]."</td>";
echo"<td>".$fecha[1]."</td>";
echo"<td>".$fecha[0]."</td>";
echo"</tr>";
}
echo"</tbody>";
echo "</table>";
?>
[/PHP]
</div>
</div>
Y basicamente lo que esto hace ES MOSTRAR TODOS TUS REG DE TU BASE DE DATOS EN UNA TABLA QUE ES CREADA DINAMICAMENTE
pon esto en el css para que sea de dos colores la tabla
Código CSS:
Ver originaltable {
border: 1px solid gray;
border-radius: 2px;
width: 700px; /* Ancho fijo para que no cambie cuando se filtra */
}
table thead {
color: white;
background: silver;
}
table tbody tr:nth-child(odd){
background-color: #E0E0F8;
color:#151515;
}
table tbody tr:nth-child(even){
background-color: #D8D8D8;
color:#B40404;
}
table thead input[type="text"] {
float: right;
}
table td {
border: 1px solid gray;
padding: 2px 4px;
border-radius: 2px;
}