I need to give these images a link from my db. I have a column in the same table that holds a link, the column is titled "product_url". I am so new to this, that everything I try keeps giving me an error. I want to make the title and the screenshots link to the product url page. Can anyone offer any advice, pls?
<div class="app-title"><?=$title?></div>
<span class="app-screenshots">
<?php
if (!empty($app['additional_images'])) echo'<span>'.$app['additional_images'].'</span>';
if (!empty($app['additional_images_2'])) echo '<span>'.$app['additional_images_2'].'</span>';
?>
I know I should at least try to provide my own answer, but I can't even do that. I've been trying for days and doing nothing but wasting my time. thank you for any help.
Maybe what you are looking for is :
echo '<span><img src="'.$app['additional_images'].'"></span>';
(if $app['additional_images']
is the link to your image file)
EDIT
If you want the image to link to a specific url, let's say 'myPage.html' :
echo '<span><a href="myPage.html"><img src="'.$app['additional_images'].'"></a></span>';
As I understand correct you have stored the URL to a picture in the database and not the binary data of the picture. Storing the binary data of a picture and the display it wouldn't make much sense. You would have to copy it to a public folder and generate an URL to use in HTML. To achieve what you want you could just use simple HTML.
<a href="[Link from DB]">
<img src="[URL of picture]" />
</a>
To use it with PHP you just echo the text:
<?php
echo "<a href=\"" . $app['product_url'] . "\">";
echo " <img src=\"" . $app['additional_images'] . "\" />";
echo "</a>";
?>
I have not tested this code! There might be syntax errors in it!
did some guessing work,
i guess $app['additional_images']
is a path to an image, and i guess $app['product_url']
is a link? if thats the case then try to reconstruct the link to the product and insert the image:
$app['additional_images']="https://www.google.com/images/srpr/logo11w.png";
$app['product_url']='<a href="http://www.example.com/product.html">The product</a>';
$temp_arr = explode(">",$app['product_url']);
$reconstruct_link_opening_tag=$temp_arr[0].">";
$reconstruct_link_closing_tag="</a>";
// your code.....
if (!empty($app['additional_images'])) echo'<span>'.$reconstruct_link_opening_tag.'<img src="'.$app['additional_images'].'">'.$reconstruct_link_closing_tag.'</span>';
// your code....
i must say, you need to clean-up your code. dont hold a complete <a href="....">....</a>
link in your array, just hold the url so its easy to manipulate, like in this case.
if the $app['product_url']
is just a url (hmm thats kinda obvious how i missed this in my first reading? hmm well you said *I have a column in the same table that holds a link, the column is titled "product_url"*) then this will do:
if (!empty($app['additional_images']))
echo'<span><a href="'.$app['product_url'].'"><img src="'.$app['additional_images'].'"></a></span>';