I have a little doubt I have been working on a form. The question is that when I load the page it evaluates everything to me and it shows me error but when I enter data it shows me the data that I request without errors.
<?php
include "mysqlcon.php";
$con = connect();
$opcion = $_POST['opcion'];
$datos = $_POST['datos'];
if ($datos <> 0) {
if ($opcion == 1) {
$consulta = "SELECT * FROM info WHERE id LIKE $datos";
}
if($opcion == 2){
$consulta = "SELECT * FROM info WHERE telefono LIKE $datos";
}
$resultado = mysqli_query($con, $consulta);
$contador = 0;
while ($misdatos = mysqli_fetch_assoc($resultado)){ $contador++;?>
<tr>
<th scope="row"><?php echo $contador; ?></th>
<td><?php echo $misdatos["id"]; ?></td>
<td><?php echo $misdatos["telefono"]; ?></td>
<td><?php echo $misdatos["nombre"]; ?></td>
<td><?php echo $misdatos["contacto"]; ?></td>
<td><?php echo $misdatos["nombre"]; ?></td>
</tr>
<?php }
}
}?>
I do not know what I'm failing, I already probe with a while but it did not work.