Jump to content

[SOLVED] Need help adding Image to PHP code! :)


Recommended Posts

Heya

Here is my Code

 

if (!empty($modSettings['down_set_t_title']))

echo  '<td><a href="' . $scripturl . '?action=downloads;sa=view;down=', $file['ID_FILE'], '">', $file['title'], '</a></td>';

 

Basicly, That sets the Title of a file on my website, and the Title of the file is at $file['title'], I Need it to make that an Image, The image is called the same as the Title so thats not a problem, It's extension is .png and its location is /images/    So Effectively I need it to be /images/$file['title'].png  How could I do this so it displays as an image?

 

Sorry If I haven't explained this very well lol

Thanks for any help! :)

Marshall

Try..

 

echo  '<td><a href="' . $scripturl . '?action=downloads;sa=view;down=' . $file['ID_FILE'] . '"><img src="/images/' . $file['title'] . '" alt="' . $file['title'] . '" /></a></td>';

 

Also removed the mix of variable joins / concatenation.

Sorry for this lol, But is there any way that I can have the title aswell as the picture? But so that when there is no picture, Only either the Alt of the picture, or the title is shown? To prevent the title being shown twice... :)

 

Sorry if it's alot to ask :)

Thanks

Marshall

No No I just need to know how to get the title in aswell as the picture, so the title next to it still, then I can just take the Alt out of the Image script and It will have the Image and the text, and if there is no Image, then the text will still show :)

Thanks :)

Oh okay, just need to jiggle it around a little..

 

echo  '<td><a href="' . $scripturl . '?action=downloads;sa=view;down=' . $file['ID_FILE'] . '"><img src="/images/' . $file['title'] . '.png" alt="" />' . $file['title'] . '</a></td>';

Hey, Sorry to bring back a sort of old topic, but I thought it was better to give you a sense of what I am doing :P

 

I have the same type of code

echo '<td align="center"><a href="' . $scripturl .

 

'?action=downloads;sa=view;down=' . $row['ID_FILE'] . '">',$row['title'],'</a><br />';

apart from the $row['title'] is the same as the $file['title'].

 

What I have is lots of pictures that are named exactly the same as the title, and I need them to come up when I hover over the title... those images are kept at the directory /images/.

 

What MrAdam gave me was perfect for what I needed and I will be keeping that on one page but this page is a little more pushed for space, so I need a Hover Over button, so when you hover over the $row['title'] it shows a picture from /images/$row['title'].png (.png at the end is fairly important lol)

 

I have a code already for this but I cannot seem to merge it, I am very bad at php lol!

Here is the Body code I have

<body>

<a id="hoverover" style="cursor:default;" onMouseOver="ShowPopup(this);"

 

onMouseOut="HidePopup();">South West Trains</a>

<div id="hoverpopup" style="visibility:hidden; position:absolute; top:0; left:0;">

<img src="http://rs-trainsim.co.uk/forums/downloads/catimgs/1.png"></font></td></tr>

</div></body>

That is for the pop-up

 

I think I explained that well... :)

Thanks for reading and any help or questions are helpful :)

Marshall

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.