6 Replies Latest reply: Jul 10, 2014 12:22 PM by matthew stuart RSS

    PHP show if wildcard

    matthew stuart Community Member

      Hi, I am trying to find a way of getting an external web link to work where the http:// is sometimes entered into the database, sometimes not. Therefore I am trying to do a show if with a wildcard that is looking for the http:// and if t's not there, then I need to add it to the link.

       

      This is what I have (I am using % as a wildcard):

       

      <?php if ($row_rs_maplistrow['fld_dURL']<>"http://%"){?>

      <a href="http://".$row_rs_maplistrow['fld_dURL']."">Website</a>

      <?php}?>

       

      <?php if ($row_rs_maplistrow['fld_dURL']=="http://%"){?>

      <a href="echo $row_rs_maplistrow['fld_dURL']">Website</a>

      <?php}?>

       

      Whatever I am doing, if the http:// is present in the DB field, I am getting a web link echoed that similar to http://http//domain.com/www.database-domain.com

       

      Obviously I am doing my wildcards wrong, but what am I doing wrong? I was thinking of doing an if else statement, but I still need to print the word 'Website' rather than print the stored address. But even then I was still getting the double http issue.

       

      Thanks.

       

      Mat