Q:

Show elements with row "lugar" value 1

I have a table with a row called lugar that have the value 1 or 2.
When I do foreach, i want to filter the elements that have the value 1 in the row lugar and the elements that have the value 2.
$descuento->lugar is the variable for the row lugar.
Actually, my code is:
    <ul id="slider">
      <?php   foreach ( $results['descuentos'] as $descuento ) { 

             $titulo = htmlspecialchars( $descuento->title );
               $title_url = limpiarCaracteresEspeciales($titulo);
               ?>

                    <li>
                        <?php if ( $imagePath = $descuento->getImagePath( IMG_TYPE_FULLSIZE ) ) { ?>
                  <img  src="<?php echo $imagePath?>" alt="<?php echo htmlspecialchars( $descuento->title )?>" />
                <?php } else {?> <img src="http://lorempixel.com/400/300/sports/" alt="<?php echo htmlspecialchars( $descuento->title )?>" /> <?php } ?>
                       <div>
                            <strong><span><?php echo htmlspecialchars( $descuento->title )?></span></strong>
                            <p><?php echo $descuento->content ?></p>
                       </div>
                   </li>
                <?php 
                } 
                ?>
     </ul>

A:

Then you could try this:
foreach ( $results['descuentos'] as $descuento )
{

   if( $descuento->lugar == 1)
   {
      $titulo = htmlspecialchars( $descuento->title );
      $title_url = limpiarCaracteresEspeciales($titulo);

      echo '<li>';

      if ( $imagePath = $descuento->getImagePath( IMG_TYPE_FULLSIZE ) )
      { 
         echo '<img  src="'. $imagePath. '" alt="'. $titulo. '" />';
      } 
      else 
      {
         echo '<img src="http://lorempixel.com/400/300/sports/" alt="'. $titulo. '" />';
      }

      echo '<div>'.
            '<strong><span>'. $titulo. '</span></strong>'.
            '<p>'. $descuento->content. '</p>'.
           '</div>'.
          '</li>';
    }
}

