
01/12/2010, 09:53
|
| | Fecha de Ingreso: julio-2009
Mensajes: 117
Antigüedad: 15 años, 8 meses Puntos: 0 | |
Respuesta: Duda con auto_increment y campo calculado Esta es la estructura de la tabla.
Código:
`id` INT( 3 ) NOT NULL AUTO_INCREMENT ,
`nombre` TEXT NOT NULL ,
`apellido1` TEXT NOT NULL ,
`apellido2` TEXT NOT NULL ,
`fechainscripcion` DATE NOT NULL ,
`fechabaja` DATE NOT NULL ,
`telefono` VARCHAR( 10 ) NOT NULL ,
`foto` BLOB NOT NULL ,
`email` TEXT NOT NULL ,
`direccion` TEXT NOT NULL
Bien al ejecutar el formulario par introducir los datos entra en juego esta pagina
Intoclientes.php
Código:
$connect = mysql_connect("bbbbbbbb","bbbbbbb","bbbbb") or die(mysql_error());
$database = mysql_select_db("bbbbbb",$connect);
$id = addslashes($_POST["id"]);
$nombre = addslashes($_POST["nombre"]);
$apellido1 = addslashes($_POST["apellido1"]);
$apellido2 = addslashes($_POST["apellido2"]);
$fechainscripcion = date ("Y-m-d");
$telefono = addslashes($_POST["telefono"]);
$foto = addslashes($_FILE["foto"]);
$email = addslashes($_POST["email"]);
$direccion = addslashes($_POST["direccion"]);
$query = mysql_query ("INSERT INTO clientes (id,nombre,apellido1,apellido2,fechainscripcion,telefono,foto,email,direccion) VALUES ('$id','$nombre','$apellido1','$apellido2','$fechainscripcion', '$telefono','$foto','$email','$direccion')") or die (mysql_error());
echo "Se ha añadido corectamente el cliente $nombre.";
echo "<meta http-equiv='refresh' content='-0;url = basededatos.php'>";
que luego regresa a la pagina "basededatos.php" para mostrar un consulta
basededatos.php
Código:
$connect = mysql_connect("db349.1and1.es","dbo348911472","llaves1234") or die(mysql_error());
$database = mysql_select_db("db348911472",$connect);
echo"<table width='750' cellspacing='0'>
<tr class='base'>
<td width='75px' align='center' class='base'>ID</td>
<td width='75px' align='center' class='base'>Nombre</td>
<td width='75px' align='center' class='base'>Primer apellido</td>
<td width='75px' align='center' class='base'>Segundo Apellido</td>
<td width='75px' align='center' class='base'>Fecha inscripcion</td>
<td width='75px' align='center' class='base'>Fecha de baja</td>
<td width='75px' align='center' class='base'>Teléfono</td>
<td width='75px' align='center' class='base'>Foto</td>
<td width='75px' align='center' class='base'>Email</td>
<td width='75px' align='center' class='base'>direccion</td>
</tr>";
$res=mysql_query($sql="SELECT * FROM clientes ORDER BY id ASC");
$res2=mysql_query($sql="SELECT fechabaja ADDDATE(fechainscripcion, INTERVAL 4 MONTH) fechabaja FROM clientes WHERE id = 1");
while($row=mysql_fetch_array($res)){
$id = $row["id"];
$nombre = $row["nombre"];
$apellido1 = $row["apellido1"];
$apellido2 = $row["apellido2"];
$fechainscripcion = $row["fechainscripcion"];
$telefono = $row["telefono"];
$foto = $row["foto"];
$email = $row["email"];
$direccion = $row["direccion"];
echo "<tr>
<td class='base' width='75px' align='center'>$id</td>
<td class='base' width='75px' align='center'>$nombre</td>
<td class='base' width='75px' align='center'>$apellido1</td>
<td class='base' width='75px' align='center'>$apellido2</td>
<td class='base' width='75px' align='center'>$fechainscripcion</td>
<td class='base' width='75px' align='center'>$fechabaja</td>
<td class='base' width='75px' align='center'>$telefono</td>
<td class='base' width='75px' align='center'>$foto</td>
<td class='base' width='75px' align='center'>$email</td>
<td class='base' width='75px' align='center'>$direccion</td>
</tr>
";
}
Asi es como tengo actualmente , por que ya he probado poner de 20 maneras la consulta adddate. |