Syntax error, unexpected 'if' (T_IF) [closed]

0

When I try to run my page, I get this error:

  

Parse error: syntax error, unexpected 'if' (T_IF) in   C: \ xampp \ htdocs \ Login18 \ Login \ vista \ admin.php on line 143

       <form method="POST" action="<?php echo $_SERVER["PHP_SELF"] ?>"> Buscar: 
      <input type="text" name="search" placeholder="Buscar folio/estado" value="<?php echo $search ?>">
     <input type="submit" value="Buscar">
     </form>
     <br><br>
     <center>
  <table class="table table-striped table-hover">
    <tr>
   <th>Folio</th>
      <th>Nombre</th>
      <th>Rut</th>
      <th>Correo</th>
      <th>Telefono</th>
      <th>Direccion</th>
      <th>Poste</th>
      <th>Solicitud</th>
      <th>Fecha</th>
      <th>Estado</th>
      <th>Reporte</th>
      <th>Borrar</th>

    </tr>
    <?php
    foreach($model as $row)
    {
    echo "<tr>";
    echo "<td>".$row['id']."</td>";
    echo "<td>".$row['nombre']."</td>";

    echo "<td>".$row['rut']."</td>";
    echo "<td>".$row['email']."</td>";
    echo "<td>".$row['phone']."</td>";
    echo "<td>".$row['direccion']."</td>";
    echo "<td>".$row['poste']."</td>";
    echo "<td>".$row['mensaje']."</td>";
    echo "<td>".$row['fecha']."</td>";
    echo "<td>".$row['estado']."</td>";
    echo "<td>".
          if($row['estado'] == 'Resuelto'){
            echo '<span class="label label-success">Resuelto</span>';
          }
                        else if ($row['estado'] == 'Pendiente' ){
            echo '<span class="label label-info">Pendiente</span>';
          }
                        else if ($row['estado'] == 'Rechazado' ){
            echo '<span class="label label-warning">Rechazado</span>';
          }

          "</td>";
    echo "<td><a href='actualizar.php?id=$row[0]' title='Editar datos' 
    class='btn btn-primary btn-sm'><span class='glyphicon glyphicon-edit' aria-hidden='true'></span></td>";
    echo "<td><a href='eliminar.php?id=$row[0]&idborrar=2'' title='Eliminar'  class='btn btn-danger btn-sm'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></a><th>";
    echo "</tr>";
    }
    ?>
    
asked by Daniela 04.06.2018 в 15:05
source

3 answers

2

You have two errors, the first is that in php you do not write else if , but elseif .

The second error is that you do not close the execution of echo that is just before the structure if :

echo "<td>".

  if($row['estado'] == 'Resuelto'){
    echo '<span class="label label-success">Resuelto</span>';
  }
                else if ($row['estado'] == 'Pendiente' ){
    echo '<span class="label label-info">Pendiente</span>';
  }
                else if ($row['estado'] == 'Rechazado' ){
    echo '<span class="label label-warning">Rechazado</span>';
  }

  "</td>";

You try to concatenate if to echo , that can not be done. The solution would be:

 echo "<td>";
          if($row['estado'] == 'Resuelto'){
            echo '<span class="label label-success">Resuelto</span>';
          }
                        elseif ($row['estado'] == 'Pendiente' ){
            echo '<span class="label label-info">Pendiente</span>';
          }
                        elseif ($row['estado'] == 'Rechazado' ){
            echo '<span class="label label-warning">Rechazado</span>';
          }

 echo "</td>";
    
answered by 04.06.2018 / 15:13
source
0

There is an error in the else if , as explained here link , should be written together elseif

I hope it's helpful

    
answered by 04.06.2018 в 15:09
0

For me, here you are missing ";"

echo "<td>".(algo) ;

and you must type elseif instead of else if

    
answered by 04.06.2018 в 15:11