How to enter a counter inside the while?


If you can help me how you could enter a counter in the while, the idea is to filter it by a range of dates shows me the information otherwise if it is out do not show me if you can help me thank you .

here is the code


// echo "hola";
$id_convenios =$_POST['id_convenios'];
$bus =$_POST['bus'];
$fechai =$_POST['fechai'];
$fechaf =$_POST['fechaf'];

$sql = "SELECT   ca.id_campanas,
esc.nombre estado_campanas,
co.nombre convenios,
ca. fc
   FROM campanas ca 
   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.nombre like '%$bus%'
   AND ca.id_convenios = '$id_convenios' 
   AND ca.estado = 'Activo'
   AND date('fecha_i') BETWEEN date('$fechai') AND date('$fechaf')
echo "</br>";
echo $sql;
$result = mysqli_query($link, $sql);

  echo "</br>";
    echo '<table class="table table-hover">

           <a class="align-middle">
              <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>

              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>

                else {
                  echo "no se encontraron resultados";
               echo "</table> <br> </div>";
asked by PAULA ANDREA 29.10.2018 в 15:15

1 answer


I do not know if I have understood your problem well, because, as someone pointed out, your question is a bit confusing. However, two things.

First, where you put if ($ rows < 0). In that scenario, that condition will never be met. The number of responses to a query will be 0, or greater, but never less.

The second. Make sure the dates reach the query in the extended ISO 8601 format, or your quotation will not work. Take a look at link .

answered by 22.12.2018 в 21:05