<?
$can = 0;
include('concha.php');

$sql = "SELECT * FROM avisos WHERE ver = 'si' ORDER BY rand() LIMIT 40";
$consulta = $conn->query($sql);
while ($row = $consulta->fetch_assoc())
{
  $ID = $row["ID"];
  $titulo = $row["titulo"];
  $linea1 = $row["linea1"];
  $linea2 = $row["linea2"];
  $IDC = $row["IDC"];
  $IDS = $row["IDS"];
  $userp = $row["user"];
  $foto = $row["foto"]; 
  $ext_img = $row["ext_img"];
  $can = $can + 1;
?>


          <div class="grid-item col-12 col-sm-6 col-md-4">

                  <h3><strong><?php echo $titulo ?></strong></h3>

            
                    
                          <?php if ($foto == NULL) {} else {?>
                          <img
                          src="upload_pic/resize_<?php echo $foto ?>.jpg" class="img-fluid"/><?php };?>
                          
                         
                    
                      <h2 class="word-wrap"><?php echo $linea1 ?></h2>
                    
                      <p><?php echo $linea2 ?></p>
                    
                    <?  
                    $sql2 = "SELECT * FROM cla_categorias WHERE ID = $IDC";
                   $consulta2 = $conn->query($sql2);
                    while ($row2 = $consulta2->fetch_assoc())
                    {
                      $nombrecat = $row2["nombre"];
                    } $consulta2->free_result();
                    
                    $sql3 = "SELECT * FROM subcategorias where ID = $IDS";
                   $consulta3 = $conn->query($sql3);
                   while ($row3 = $consulta3->fetch_assoc())
                    {
                      $nombresub = $row3["nombresub"];
                    } $consulta3->free_result();
                    ?>
                    
                          <span class="Estilo4">&raquo; <?php echo $nombrecat ?> &raquo; <?php echo $nombresub ?></span>
                    
                    
                    <a href="anuncio.php?ID=<?php echo $ID ?>">Ver Anuncio</a>
                    
         
          </div>


<? } $consulta->free_result();
?>

    <div align="center"><br />
      <? if ($can == 0) { ?>
      <span class="Estilo42"> AUN NO HAY AVISOS PUBLICADOS EN ESTE RUBRO</span>
      <? } ?>
    </div>