1,105,310 Community Members

need to display <img src => as text on a page

Member Avatar
GraficRegret
Junior Poster
182 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

I need to allow my customer to upload a picture and then display the image source tag for the picture so they can copy it and paste it where they want to in the text area I am providing for them. i.e. how facebook notes works

LastMitch
Deleted Member
 
0
 

@GraficRegret

need to display <img src => as text on a page

I don't know about Facebook feature. But this question is more suited for CSS than PHP but to answer your question it should look like this:

<img src="image/image.jpg" width="800px" height="600px" alt="caption or text" />

The alt is where the caption appear.

Member Avatar
GraficRegret
Junior Poster
182 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

I know how to use it I need to be able to "echo" it to a page so the person uploading the photo to the server can copy and paste it because they don't know how to write code and they don't want to know how.

LastMitch
Deleted Member
 
0
 

@GraficRegret

I know how to use it I need to be able to "echo" it to a page so the person uploading the photo to the server can copy and paste it because they don't know how to write code and they don't want to know how.

1) You need to create a simple form to submit the caption
2) You need to create a table in the database so when you submit your data from the form it will go to the database.
3) The you need to create a query to select the caption.
4) Now you can just echo the caption (wherever your image is place)

Does that make sense?

Member Avatar
Atli
Practically a Master Poster
691 posts since May 2007
Reputation Points: 182 [?]
Q&As Helped to Solve: 107 [?]
Skill Endorsements: 16 [?]
 
0
 

If you need to show HTML source code on a HTML page, run the HTML source through the htmlentities() function. That will convert it so the browse will show it as text rather than render it as HTML.

Member Avatar
GraficRegret
Junior Poster
182 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks

Member Avatar
NardCake
Posting Pro in Training
416 posts since Oct 2012
Reputation Points: 30 [?]
Q&As Helped to Solve: 30 [?]
Skill Endorsements: 9 [?]
 
0
 

Or you could slap some <code></code> tags around it.

LastMitch
Deleted Member
 
0
 

@GraficRegret

If you are gonna to used htmlentities() function, your client won't be able to echo out the caption correctly because of the backslashes. This is the only drawback. It really depend how you used this function.

Member Avatar
Atli
Practically a Master Poster
691 posts since May 2007
Reputation Points: 182 [?]
Q&As Helped to Solve: 107 [?]
Skill Endorsements: 16 [?]
 
0
 

Or you could slap some <code></code> tags around it.

That's not enough. Neither the <code> nor <pre> tags will stop the browser from actually rendering HTML strings. They are simply styling tags; essentially the equivalent of using <span> or <p> tags with monospace fonts and white-spaces preserved.

There is one thing worth pointing out though. If you echo the unmodified HTML code into a <textarea>, most browsers will not render it as HTML, but rather show the HTML source in the area. However you should still encode the HTML entities with the htmlentities function. It's unwise to leave any HTML code that isn't actually meant to be rendered as HTML in there unmodified.

If you are gonna to used htmlentities() function, your client won't be able to echo out the caption correctly because of the backslashes.

How do you mean? The htmlentites function does not generate any backslashes. All it does is convert all applicable characters in the given string to their respective HTML entities. Are you perhaps confusing this with the addslashes function?

Member Avatar
GraficRegret
Junior Poster
182 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

thanks for the help yall, i will mark as solved for the time being and after i find out what works i will reply to you all in thanks ro ask for mor help, thanks for your time

Question Answered as of 1 Year Ago by LastMitch, Atli and NardCake
Member Avatar
GraficRegret
Junior Poster
182 posts since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

thank you all very much the code that you gave me works beautifully you were all very helpfull.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article