Hide data from a table

1

Good day, as I do so that when I open the next program and at the time of doing any search, I do not get the data that I have stored in the table I have in mysql. This is the program:

This is the code of that program:

This part creates the input and the table where the searched data will be stored:

 <title>busqueda</title>
 <p>
 <form name="form1" method="POST" action="busqueda.php" id="cdr">
 <h2>Buscar Usuario</h2>
 <input name="busca" type="text" id="busqueda" placeholder="Ingrese el día">
 <input name="mes" type="text" id="mesqueda" placeholder="Ingrese el mes">
 <input name="año" type="text" id="añoqueda" placeholder="Ingrese el año">
 <br><br>
 <input type="submit" name="submit" value="Buscar"> 
 </p>
 </form>

 <table width="500" border="1" id="tab">
 <tr>
 <td width="60">Día</td>
 <td width="90">Mes</td>
 <td width="90">Año</td>
 </tr>  

This is the part of the code with which php and mysql are linked and with which the search is made to the database:

 <?php
 error_reporting(E_ALL ^ E_NOTICE);
 $busca="";
 $mes="";
 $año="";
 $busca=$_POST['busca'];
 $mes=$_POST['mes'];
 $año=$_POST['año'];
 $con=mysqli_connect('localhost','root','');
 mysqli_select_db($con,"tutorial");
 if ($con->connect_errno) {
    echo "no conectado";
}
$con->real_query("SELECT * FROM entrada WHERE dia like '%$busca%' and mes LIKE '%$mes%' and anio like '%$año%'");
$resultado= $con->use_result();

?>

And this is the part of the php code that embeds these search results in the table:

 <?php
while($muestra=$resultado->fetch_assoc()){
echo'<tr>';
echo'<td>'.$muestra['dia'].'</td>';
echo'<td>'.$muestra['mes'].'</td>';
echo'<td>'.$muestra['anio'].'</td>'; 
echo'</tr>';
 }

 ?>
 </table>

I appreciate any help !!

    
asked by julian vargas 24.03.2018 в 20:16
source

1 answer

0

You should remove this part of the code since the fetch_assoc retrieves a row of results as an associative array, so as long as there are rows in your database it will show you the day, month and year fields.

<?php
while($muestra=$resultado->fetch_assoc()){
echo'<tr>';
echo'<td>'.$muestra['dia'].'</td>';
echo'<td>'.$muestra['mes'].'</td>';
echo'<td>'.$muestra['anio'].'</td>'; 
echo'</tr>';
 }

 ?>
    
answered by 25.03.2018 в 04:07