I have a table with 4 fields: No tuition , Last name , Names and State .
>I want to do a search on the surname and if for example I search only those that are named Velez, I list the information of all those who are named Velez.
I have this form
<form name="consulta2" method="post" action="resultado1.php">
<input placeholder="Buscar por Apellido Paterno:" type="text" name="busca" maxlength="25" class="input-search"><br/>
<input type="submit" id="submit" value="Buscar">
</form>
And the process is in:
$busca = $_POST['busca'];
$sql = "SELECT coleap, colenom, estado FROM psicologos WHERE coleap LIKE %$busca% ";
echo $sql;
$result = mysql_query($sql);
//se despliega el resultado
echo "<div align='center'>";
echo "<table style='border:1px solid #CCCCCC; width:80%';>";
echo "<tr>";
echo "<th style='font-family:Arial; border-right:1px solid #ccc; text-align:center; border-bottom:1px solid #ccc; font-size:13px'>Apellidos</th>";
echo "<th style='font-family:Arial; border-right:1px solid #ccc; text-align:center; border-bottom:1px solid #ccc; font-size:13px'>Nombres</th>";
echo "<th style='font-family:Arial; border-right:1px solid #ccc; text-align:center; border-bottom:1px solid #ccc; font-size:13px'>Estado</th>";
echo "</tr>";
while ($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td style='font-family:Arial; border-right:1px solid #ccc; text-align:center; font-size:13px'>" . $row[0] . "</td>";
echo "<td style='font-family:Arial; border-right:1px solid #ccc; text-align:center; font-size:13px'>" . $row[1] . "</td>";
echo "<td style='font-family:Arial; border-right:1px solid #ccc; text-align:center; font-size:13px'>" . $row[2] . "</td>";
echo "</tr>";
}
echo "</table>";
But it does not work for me, or it does not show me anything or it shows me the whole list without any filter What am I wrong?