vendredi 1 avril 2016

Using if-statements in PHP to print HTML

I'm fairly new to PHP and I've been trying to construct some code to print basic HTML, however the code causes an error 500 whenever used. I am guessing it is a syntax error since I've tried the code in a couple of forms and nothing seems to work (including removing the database lookup and just trying to compare to set values to each other). The script needs to get a variable from the db, compare it to a set value and print the HTML if true, here is the code I am trying:

<?php
    $db = &JFactory::getDBO();
    $id = JRequest::getString('id');
    $db->setQuery('SELECT #__categories.title FROM #__content, #__categories WHERE #__content.catid = #__categories.id AND #__content.id = '.$id);
    $category = $db->loadResult(); ?>
  <?php if strcmp($category,"Blog")==0 : ?>

      <div style="display: -webkit-inline-box" class="sharelogos">
        <a href="http://ift.tt/136R2E6 echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>" target="_blank">  <img src="/images/sharing-icons/facebook.png" width="30px" alt="Facebook" /></a>
      </div>

<?php endif; ?>

Any help will be appreciated, thanks!

Aucun commentaire:

Enregistrer un commentaire