
03/05/2010, 15:36
|
| | Fecha de Ingreso: marzo-2010
Mensajes: 9
Antigüedad: 15 años Puntos: 0 | |
Respuesta: Consulta en PHP Se me olvidaba, este es el codigo que me funciono:
<html>
<head>
<title>Busqueda</title>
</head>
<body>
<style type="text/css">
<!--
body {
background-color: #3CF;
background-image: url(imagenes/logo_fondo.jpg);
background-repeat: repeat;
}
-->
</style>
<h1>Resultado de Busqueda</h1>
<?php
$camion = Trim(stripslashes($_POST['camion']));
$fecha1 = Trim(stripslashes($_POST['fechaenteraini']));
$fecha2 = Trim(stripslashes($_POST['fechaenterafin']));
if (!$fecha1 || !$fecha2)
{
echo "No has introducido los detalles de la busqueda. Por favor vuelve e inténtalo de nuevo.";
exit;
}
$camion = addslashes($camion);
$fecha1 = addslashes($fecha1);
$fecha2 = addslashes($fecha2);
@ $db = mysql_pconnect("localhost", "root", "zxcv");
if (!$db)
{
echo "Error: No se ha podido conectar a la base de datos. Por favor, prueba de nuevo más tarde.";
exit;
}
mysql_select_db("dimension");
$consulta = "select * from carga_combustible where camion like '$camion' and fecha>='$fecha1' and fecha<='$fecha2'";
$resultado = mysql_query($consulta) or die (mysql_error());
$num_resultados = mysql_num_rows($resultado);
echo "<p>Resultados Encontrados: ".$num_resultados."</p>";
for ($i=0; $i <$num_resultados; $i++)
{
$row = mysql_fetch_array($resultado);
echo "<p><strong>".($i+1).". Camión: ";
echo stripslashes($row["camion"]);
echo "</strong><br>Fecha: ";
echo stripslashes($row["fecha"]);
echo "<br>Combustible: ";
echo stripslashes($row["litros"]);
echo "</p>";
}
?>
</body> |