create table productos(
idproducto integer not null auto_increment,
descripcion varchar(100) not null,
presentacion varchar(50) not null,
preciounitario float,
cantidadventa float,
stock float,
fechaventa
date,
primary key(idproducto)
)
Segundo:
Código
del archivo conexión.php
<?php
function conectar()
{
mysql_connect("localhost", "root", "123");
mysql_select_db("tienda");
}
function desconectar()
{
mysql_close();
}
?>
Tercero:
<html>
<head>
<title>Mostrar
Datos</title>
</head>
<body>
<?
include
"conexion.php";
conectar();
$consulta=mysql_query("select * from productos");
while($registro=mysql_fetch_array($consulta))
{
echo $registro['idproducto']." ";
echo $registro['descripcion']." ";
echo $registro['presentacion']." ";
echo $registro['preciounitario']." ";
echo $registro['cantidadventa']." ";
echo $registro['stock']." ";
echo $registro['fechaventa']."<br>";
}
desconectar();
?>
</body>
</html>
Cuarto: Muestra de datos:
<html>
<head>
<title>Mostrar
Datos</title>
</head>
<body>
<?
include
"conexion.php";
conectar();
$consulta=mysql_query("select * from productos");
echo "<table border=1>";
while($registro=mysql_fetch_array($consulta))
{
echo "<tr>";
echo "<td>".$registro['idproducto']."</td>";
echo "<td>".$registro['descripcion']."</td>";
echo "<td>".$registro['presentacion']."</td>";
echo "<td>".$registro['preciounitario']."</td>";
echo "<td>".$registro['cantidadventa']."</td>";
echo "<td>".$registro['stock']."</td>";
echo "<td>".$registro['fechaventa']."</td>";
echo "</tr>";
}
echo "</table>";
desconectar();
?>
</body>
</html>
Hecho por anonymouS....!!!!

No hay comentarios:
Publicar un comentario