samedi 2 septembre 2017

If else PHP statement with variable inside href and li

I have URLs in the database being called by either with $p_camping or $p_hiking

if they're empty, they echo nothing, if the table contains a url for hiking/camping, it will echo a url in an li.

It properly shows empty if the table cell is empty, but it will not echo the href in an li properly, it just spits out the full html link without an li or line break

I've tried countless ways of writing the echos but nothing seems to work, below are two i've tried

<!-- HTML -->

 <ul>
    <? echo "$p_camping" ?>
    <? echo "$p_hiking" ?>
 </ul>
 
 
 <!-- PHP INCLUDE with two variations i've tried out of many -->
 
 $row = mysqli_fetch_array($result);
  $p_camping = $row['p_camping'];
  $p_hiking = $row['p_hiking'];
    
  
 else
{
  echo "<li><a href='".$p_camping."'>Camping Info</a></li>";  
}


if(empty($row['$p_hiking']))
{
    // it's empty!
    echo " ";
}
else
{
  echo "<li><a href=\"$p_hiking\">Hiking Info</a></li>";  
}

Aucun commentaire:

Enregistrer un commentaire