<?php
$base='clientes';
$usuario='root';
$pass='12345';
$host='localhost';
mysql_connect($host,$usuario,$pass) or die('error en la conexion');
mysql_select_db($base) or die('error en la seleccion de la base de datos');
?>
Archivo 2. formulario.php
<link href="la_tabla.css" rel="stylesheet" type="text/css" />
<?php
include("conexion.php");
?>
<form action='enviar_datos.php' method='POST'>
<table>
<tr>
<td>Nit</td>
<td><input type='text' name='nit'/></td>
</tr>
<tr>
<td>Nombre</td>
<td><input type='text' name='nombre'/></td>
</tr>
<tr>
<td> </td>
<td><input type='submit' value='Enviar'</td>
</tr>
</table>
</form>
<?php
$texto_consulta="select * from proveedores";
$datos_consulta=mysql_query($texto_consulta);
?>
<table border='1'>
<tr>
<th colspan='2'>Lista de proveedores</th>
</tr>
<tr>
<th>Nit</th>
<th>Nombre</th>
</tr>
<?php
while($fila_consulta=mysql_fetch_array($datos_consulta))
{
?>
<tr>
<td>
<?php echo $fila_consulta['nit']; ?>
</td>
<td>
<?php echo $fila_consulta['nombre'] ?>
</td>
</tr>
<?php
}
?>
</table>
Archivo 3. enviar_datos.php
<?php
include("conexion.php");
$nit=$_REQUEST['nit'];
$nombre=$_REQUEST['nombre'];
$texto_insercion="insert into proveedores(nit,nombre) values('$nit','$nombre')";
mysql_query($texto_insercion) or die(mysql_error()."el texto de la consulta fue".$texto_insercion);
?>
<script>location.href='formulario.php'</script>
Estilos para tablas en este enlace