CODIGO PARA CONECTAR BASE DE DATOS 1
<?php
$host ="localhost";
$usuario ="root";
$password="root";
$database="tienda1";
$conec=@mysql_connect($host,$usuario,$password) or die(mysql_error());
$db =@mysql_select_db($database,$conec) or die(mysql_error());
?>
CODIGO PARA LA LISTA 1
<html>
<?php
include "conectar.php";
?>
<body>
<h3>LISTA DE PRODUCTOS </h3> <br>
<hr>
<table border='1'>
<tr><td>CODIGO</td> <td> DESCRIPCION </td> <td> PRECIO </td>
</tr>
<?php
$sql="select * from producto";
$res=mysql_query($sql,$conec);
while($row=@mysql_fetch_array($res))
{
echo"";
echo"<tr>";
echo"<td>"; echo $row['codigo']; echo"</td>";
echo"<td>"; echo $row['descripcion']; echo"</td>";
echo"<td>"; echo $row['precio']; echo"</td>";
echo"</tr>";
echo"";
}
?>
</table>
<body>
</html>
CODIGO 2
<?php
$host ="localhost";
$usuario ="root";
$password="root";
$database="clientes";
$conec=@mysql_connect($host,$usuario,$password) or die(mysql_error());
$db =@mysql_select_db($database,$conec) or die(mysql_error());
?>
CODIGO DE CLIENTES 2
<html>
<link rel="stylesheet" href="css/sin_linea.css">
<?php
include "conectar1.php";
?>
<body bgcolor="#00ace6">
<header> <center>
<h3>lista de clientes </h3></center></header>
<form method="post"action="cliente.php">
<fieldset>
<legend>
datos del cliente
</legend> <table border="1">
<tr>
<td>dni</td><td><input type= "text" name="txcod" id="txcod"></td>
</tr><tr>
<td> nombre </td> <td><input type= "text" name="txdes" id="txdes"></td> </tr>
<tr>
<td> direccion </td><td><input type= "text"name="txpre" id="txpre"></td></tr>
</tr></table >
</fieldset>
<fieldset>
<legend> lista de clientes </legend>
<table border='1'>
<tr bgcolor="#FF0000">
<td>CODIGO</td>
<td> DESCRIPCION </td>
<td> PRECIO </td>
</tr>
<?php
$sql="select * from cliente1";
$res=mysql_query($sql,$conec);
while($row=@mysql_fetch_array($res))
{
echo"";
echo"<tr bgcolor= #b38600>";
echo"<td>"; echo $row['dni']; echo"</td>";
echo"<td>"; echo $row['nombre']; echo"</td>";
echo"<td>"; echo $row['direccion']; echo"</td>";
echo"</tr>";
echo"";
}
?>
</table></fieldset>
<fieldset>
<legend> opciones
</legend>
<button> <input type="submit" value="guardar" name="g" id="g"> </button>
<button> <input type="button" value="salir"> </button></fieldset>
<?php
mysql_query("set names'utf8'");
$sql="select * from cliente1";
$result=mysql_query($sql,$conec);
$codi=$_POST['txcod'];
$desc=$_POST['txdes'];
$prec=$_POST['txpre'];
$sql="insert into cliente1(dni,nombre,direccion) values ('$codi','$desc','$prec')";
$result=mysql_query($sql,$conec);
?>
</form>
<body>
<style>
TR:HOVER {
background:#EEEEEE;
}
button{
text-align: center;
color: white;
background-color:black; rgb(211, 15, 25);
padding: 5px;
font-size: 18px;
font-family: Impact;
}
header{
background-color: #24282b;
color: #fff;
padding-top: 10px;
min-height: 30px;
border-bottom: 2px solid #1293d4;
}
</style>
</html>
CODIGO FINAL DE LISTA DE PRODUCTOS
<html>
<link rel="stylesheet" href="css/sin_linea.css">
<?php
include "conectar.php";
?>
<body bgcolor="#00ace6">
<header> <center>
<h3>mantenimiento de productos </h3></center></header>
<form method="post"action="producto_new.php">
<fieldset>
<legend>
datos del producto
</legend> <table border="1">
<tr>
<td>CODIGO</td><td><input type= "text" name="txcod" id="txcod"></td>
</tr><tr>
<td> DESCRIPCION </td> <td><input type= "text" name="txdes" id="txdes"></td> </tr>
<tr>
<td> PRECIO </td><td><input type= "text"name="txpre" id="txpre"></td></tr>
</tr></table >
</fieldset>
<fieldset>
<legend> lista de productos </legend>
<table border='1'>
<tr bgcolor="#FF0000">
<td>CODIGO</td>
<td> DESCRIPCION </td>
<td> PRECIO </td>
</tr>
<?php
$sql="select * from producto";
$res=mysql_query($sql,$conec);
while($row=@mysql_fetch_array($res))
{
echo"";
echo"<tr bgcolor= #b38600>";
echo"<td>"; echo $row['codigo']; echo"</td>";
echo"<td>"; echo $row['descripcion']; echo"</td>";
echo"<td>"; echo $row['precio']; echo"</td>";
echo"</tr>";
echo"";
}
?>
</table></fieldset>
<fieldset>
<legend> opciones
</legend>
<button> <input type="submit" value="guardar"name="g"id="g"> </button>
<button> <input type="button" value="salir"> </button></fieldset>
<?php
mysql_query("set names'utf8'");
if($_POST['txcod']=='' and $_POST['g'])
{}
else
{
if ($_POST['txcod']=='')
{ echo "Faltan datos";}
else
{
$codi=$_POST['txcod'];
$desc=$_POST['txdes'];
$prec=$_POST['txpre'];
$sql="insert into producto (codigo,descripcion,precio)
values ('$codi','$desc','$prec')";
$result=mysql_query($sql,$conec);
echo"<meta http-equiv='refresh'content='l':url=producto_new.php";
}
}
?>
</form>
<body>
<style>
TR:HOVER {
background:#EEEEEE;
}
button{
text-align: center;
color: white;
background-color:black; rgb(211, 15, 25);
padding: 5px;
font-size: 18px;
font-family: Impact;
}
header{
background-color: #24282b;
color: #fff;
padding-top: 10px;
min-height: 30px;
border-bottom: 2px solid #1293d4;
}
</style>
No hay comentarios.:
Publicar un comentario