title: Display HTML friendly special characters with PHP from a MySQL db
body: <p>I'm from Mexico, so our strings contain some special characters that need to be stored and later displayed. Is there a way (using PHP) to encode a string from MySQL and use it in html?</p>
  
  <pre><code>  &lt;?php 
      function especialidades($dbcesp){
          $q="SELECT NombreEspecialidad FROM especialidad;";
          $r=mysqli_query($dbcesp, $q);
  
          while ($esp=mysqli_fetch_assoc($r)) {
              ?&gt;
              &lt;button type="button" class="btn btn-default"&gt;&lt;?php echo $esp['NombreEspecialidad']; ?&gt;&lt;/button&gt;
              &lt;?php
          }
      } 
     ?&gt;
  </code></pre>
  
  <p>This is the way I retrieve and generate some buttons for my webpage, but for some reason, aren't displayed correctly.</p>