It turns out that I want to do a search through ajax where I have three fields one is idpaciente another is cedula and the other is name.
What I want to do is to search first by idpaciente if it does not find search by cedula and if it does not find a cedula search like ´%$nombre%´
to launch the results more sercanos of the name sent but it turns out that in my select only responds to the last Search condition by name and use separator or below I leave the code so you have an idea.
<?php
include('../conexion.php');
$idp=$_POST['idp']; #idpaciente
$cd=$_POST['cd']; #cedula
$n=$_POST['n']; #nombre
?>
<table class="tblmicentro">
<tr>
<th>idp</th>
<th>Nombre</th>
<th>Apellidos</th>
<th>Nacionalidad</th>
<th>Cedula</th>
<th>acciones</th>
</tr>
<?php
$n2="0";
$sql2="SELECT * FROM perfil_paciente where (idpaciente='$idp' or cedula='$cd') or nombres like '%$n%'";
$result2=mysqli_query($conexion, $sql2);
while ($m2=mysqli_fetch_assoc($result2)) {
$n2++;
?>
<tr>
<td><span class="numeracion"><?php echo $n2 ?></span></td>
<td><span class="numeracion"><?php echo $m2['idpaciente'] ?></span></td>
<td><?php echo $m2['nombres'] ?></td>
<td><?php echo $m2['apellidos'] ?></td>
<td><?php echo $m2['nacionalidad'] ?></td>
<td></td>
</tr>
<?php
}
?>
</table>
thanks.