Hola todos tengo un buscador en php el cual el me busca en mi BD y pues trabaja muyyyy bien a la mil maravillas pero he tratado que en ves de buscar usando un solo campo me busque usando dos campos es que necesito buscar datos entre fechas por ejemplo que busque registros entre una fecha y otra los campos seria Fecha y Fecha2 aquí les dejo el código para ver que me pueden ayudar y si alguien necesita el código pues lo pueden usar:
Código PHP:
<?php
$link = mysql_connect("localhost", "hola", "VVVVV") or die ("Error en la Base de iyc");
$bd=mysql_select_db("basededatos",$link) or die ("Verifique la Base de iyc");
$Fecha_vab=$_POST["Fecha"];
$Fecha2_vab=$_POST["Fecha2"];
if ($Fecha_vab!="")
{
$sql=mysql_query("SELECT * from `iyc` WHERE Fecha LIKE '%$Fecha_vab%' OR Fecha2 LIKE '%$Fecha2_vab%'",$link);
if (mysql_num_rows($sql)>0)
{
$tabla=mysql_query("SELECT * from `iyc` WHERE Fecha LIKE '%$Fecha_vab%' OR Fecha2 LIKE '%$Fecha2_vab%'",$link);
while ($registro = mysql_fetch_array($tabla))
{
echo '<table border="1" width="100%" id="table1" bordercolor="#000000" cellspacing="1" height="83" cellpadding="0" style="border-collapse: collapse">';
echo '<tr>';
echo '<td><p align="justify" style="margin-left: 5px"><b>FECHA<b></td>';
echo '<td><p align="center"><b>PLANILLA<b></p></td>';
echo '<td><p align="justify" style="margin-left: 5px"><b>DECLARACIÓN<b></td>';
echo '<td><p align="justify" style="margin-left: 5px"><b>PERIODO<b></td>';
echo '<td><p align="justify" style="margin-left: 5px"><b>TOTAL<b></td>';
echo '<td><p align="justify" style="margin-left: 5px"><b>ESTADO<b></td>';
echo '</tr>';
$tabla=mysql_query("SELECT * from `iyc` WHERE Fecha LIKE '%$Fecha_vab%' OR Fecha2 LIKE '%$Fecha2_vab%'",$link);
while ($registro = mysql_fetch_array($tabla))
{
echo '<tr>';
echo '<td width="5" height="30">' . $registro['Fecha'] . '</td>';
echo '<td><p align="center">' . $registro['Inicial'] . '' . $registro['Id'] . '</p></td>';
echo '<td><p align="justify" style="margin-left: 5px">' . $registro['Declara1'] . ' </td>';
echo '<td><p align="justify" style="margin-left: 5px">' . $registro['T1'] . ' <font color="#0000FF">' . $registro['T2'] . '</font> ' . $registro['T3'] . ' <font color="#0000FF">' . $registro['T4'] . '</font> ' . $registro['Anios2'] . '</td>';
echo '<td><p align="justify" style="margin-left: 5px">' . $registro['total'] . ' Bs.</td>';
echo '<td><p align="justify" style="margin-left: 5px">' . $registro['Estado'] . ' </td>';
echo '</tr>';
}
echo '</table>';
}
}
else
{
echo "¡No existen resultados para tu búsqueda!\n";
}
}
else
{
echo "<b>Error:</b> ¡Debes ingresar los iyc correctamente!\n";
}
?>
De ante mano gracias por la ayuda que me puedan dar