Good morning, I have tried to perform a search to a database in the following way .. I have a database with x columns (suppose that for more ease, the database has only two columns, a column that day is called and another called month), what I want to do is that by means of an input search only in the day column and through another different input search only in the month column, if I want to search only in day there is no problem, if I want to search only in month there is no problem and if I want to search both day and month at the same time there is no problem. Here I attach the code that I have and it does not work :(
This is the part of the code of the page that performs the searches (where the two input are):
<title>busqueda</title>
<p>
<form name="form1" method="POST" action="busqueda.php" id="cdr">
<h2>Buscar Usuario</h2>
<input name="dia" type="text" id="busqueda">
<input name="mes" type="text" id="mesqueda">
<input type="submit" name="submit" value="Buscar">
</p>
</form>
This is the part of the code with which php and mysql are linked and with which the search is made to the database (I am 100% sure that $ query must be corrected, which is where the search is made in the base of data, but I do not know how to do it so that it is as I want):
<?php
error_reporting(E_ALL ^ E_NOTICE);
$dia="";
$mes="";
$dia=$_POST['dia'];
$mes=$_POST['mes'];
$con=mysqli_connect('localhost','root','');
mysqli_select_db($con,"tutorial");
if(($dia And $mes) !=""){
$query = "SELECT * FROM entrada WHERE dia LIKE '%$dia%' and mes LIKE
'%$mes%'";
$busqueda=mysqli_query($con,$query);
}
?>
And this is the part of the html code that creates the table where the results of the search will be embedded and the php that embeds these search results in the table:
<table width="805" border="1">
<tr>
<td width="75">Día</td>
<td width="136">Mes</td>
<td width="225">Año</td>
</tr>
<?php
while($muestra=mysqli_fetch_array($busqueda)){
echo'<tr>';
echo'<td>'.$muestra['dia'].'</td>';
echo'<td>'.$muestra['mes'].'</td>';
echo'<td>'.$muestra['anio'].'</td>';
}
?>
</table>
Any help will be very grateful.