justlukeyou Posted February 6, 2011 Share Posted February 6, 2011 Hi, I have a peice of code which publishes an image with a link from my database. However I cant get it to use external links. My code is: echo "<a href=\"" .$link . "\"> <img src=\"" .$image ."\" /> </a><BR />"; I have tried all the options I can think of but I cant get it work. Can anyone advise please? Quote Link to comment https://forums.phpfreaks.com/topic/226897-php-external-links/ Share on other sites More sharing options...
BlueSkyIS Posted February 6, 2011 Share Posted February 6, 2011 what does the HTML output look like (view source)? Quote Link to comment https://forums.phpfreaks.com/topic/226897-php-external-links/#findComment-1170730 Share on other sites More sharing options...
Cagecrawler Posted February 6, 2011 Share Posted February 6, 2011 The HTML itself looks fine. Where are $link and $image being set? Quote Link to comment https://forums.phpfreaks.com/topic/226897-php-external-links/#findComment-1170731 Share on other sites More sharing options...
BlueSkyIS Posted February 6, 2011 Share Posted February 6, 2011 The HTML itself looks fine. Where are $link and $image being set? yes, the code producing the HTML looks fine, but what does the HTML output look like after execution? Quote Link to comment https://forums.phpfreaks.com/topic/226897-php-external-links/#findComment-1170733 Share on other sites More sharing options...
Pikachu2000 Posted February 6, 2011 Share Posted February 6, 2011 What are the values of $link and $image? There's no need for all that string concatenation BTW; it just creates more opportunities for errors. echo "<a href=\"$link\"> <img src=\"$image\" /></a><BR />"; Quote Link to comment https://forums.phpfreaks.com/topic/226897-php-external-links/#findComment-1170734 Share on other sites More sharing options...
justlukeyou Posted February 6, 2011 Author Share Posted February 6, 2011 Hi, This publishes the images with in a column down the page. I have tried the code above but it only publishes the first image in the database. Is there a way of using external links in PHP? Quote Link to comment https://forums.phpfreaks.com/topic/226897-php-external-links/#findComment-1170755 Share on other sites More sharing options...
ChemicalBliss Posted February 6, 2011 Share Posted February 6, 2011 What do you mean external links? echo "<a href=\"http://" .$link . "\"> <img src=\"" .$image ."\" /> </a><BR />"; Quote Link to comment https://forums.phpfreaks.com/topic/226897-php-external-links/#findComment-1170809 Share on other sites More sharing options...
justlukeyou Posted February 7, 2011 Author Share Posted February 7, 2011 Hi, I am trying to open a link from my database into a black tab. Can I try this: "target=\"_blank\">" Will this use the " without messing up the PHP script? Quote Link to comment https://forums.phpfreaks.com/topic/226897-php-external-links/#findComment-1170942 Share on other sites More sharing options...
cyberRobot Posted February 7, 2011 Share Posted February 7, 2011 Hi, I am trying to open a link from my database into a black tab. Can I try this: "target=\"_blank\">" Will this use the " without messing up the PHP script? Yep, adding the target attribute to the anchor tag should work. Note that this should open the link in a new window (depending on the browser settings). I don't know if there is a way to open the link in a new tab. I think that's up to the browser settings. Quote Link to comment https://forums.phpfreaks.com/topic/226897-php-external-links/#findComment-1170956 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.