If you can help me with the following syntax of the code what happens I'm doing a search engine and I'm doing it by filter that consists of a list where it brings me the records that are in the database, plus generate 2 input date one for the initial date and another for the final date, what happens is that at the time of filtering it is not bringing what I need for example if my table is called campaign and has an initial date another a final date the idea is that if the initial date was created on 10/6/2018 and the final date was on 11/10/2018 the idea is to show me the data according to that range of dates otherwise if the date is different then do not bring me the information, thank you very much if you can help me.
$sql = "SELECT ca.id_campanas,
ca.nombre,
esc.nombre estado_campanas,
co.nombre convenios,
ca.presupuesto,
ca. fc
FROM campanas ca . nombre
INNER JOIN estado_campanas esc ON esc.id_estadoc = ca.id_estadoc
INNER JOIN convenios co ON co.id_convenios = ca.id_convenios
WHERE ca.id_campanas = '$bus'
AND ca.id_convenios = '$id_convenios'
AND ca.estado = 'Activo'
AND date('fecha_i') BETWEEN date('$fechai') AND date('$fechaf')";
$result = mysqli_query($link, $sql);
if($fechai <= $fechaf) {
echo "</br>";
echo '<table class="table table-hover">
<a class="align-middle">
<thead>
<tr style="background:#e1e2e6;">
<th style="color: #1674ae;text-align: center;">Nombre de la Campaña</th>
<th style="color: #1674ae;text-align: center;">Nombre Estado de la Campaña</th>
<th style="color: #1674ae;text-align: center;">Nombre del Convenio</th>
<th style="color: #1674ae;text-align: center;">Presupuesto</th>
<th style="color: #1674ae;text-align: center;">Fecha de Creación</th>
</tr>
</thead>';
while ($filas = mysqli_fetch_array($result))
{
echo "<tr>
<td style='text-align: center'>$filas[nombre] </td>
<td style='text-align: center'>$filas[estado_campanas]</td>
<td style='text-align: center'>$filas[convenios]</td>
<td style='text-align: center'>$filas[presupuesto]</td>
<td style='text-align: center'>$filas[fc]</td>
</tr>";
}
echo "</table> <br> </div>";
}else {
echo "No se encontraron resultados";
}