Jump to content

Recommended Posts

Hi

 

I have a page pulling information from mysql table,  it lists names, I have these inside a hyperlink so that where there is a website listed for that record then the user can click on the name and move to their website.  Only thing is that what happens if there is not a website for that record.  I wanted a script so that if there is a website address listed then it prints the hyperlink but where there is not a website address listed that only the name is printed and it is not a hyperlink.  I understand that the strpos can be used for this

 

I have written a script but it is only printing out the name even when there is a website address in the row.  What is wrong?

PHP Version 5.3.4  Any help very much appreciated

 

<?php
               $website = $org_website;
               $link = 'http'; 
               $weblink = strpos ($website,$link);

                  if ($weblink === !false)  {
                  echo "<a href=\"$org_website;\"> FindOrganiserName($org_id); \">
                  FindOrganiserName($org_website); </a>";
                  }
                  else {
                     echo FindOrganiserName($org_id);
                  }

                     ?>

Link to comment
https://forums.phpfreaks.com/topic/246053-strpos-with-if-statement-not-working/
Share on other sites

hi all

 

thank you for your help this is the code that is working for me,  thank you for your help

 

<?php

$website = $org_website;

$link = 'http';

$weblink = strpos ($website,$link);

 

if ($weblink !== FALSE )  {

echo "<a href=\"$org_website\" target=\"_blank\"> $org_name </a>";

}

else {

echo FindOrganiserName($org_id);

}

 

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.