There is a form. It has text area,a text field and an upload image option.
I want that if the user writes some paragraph and wants the image to be displayed exactly above next paragraph, then he/she write a unique keyword like 'imagehere' in text area as well as in text field.
this unique text would be stored in another column.
Then while retriving the text from database, if there is such keyword then replace it with
<img src="path">
tag
Is this correct way to display images according to position defined by user?
It works!
I wanted to do this to avoid asking the user to write
<img src="photos/uploadedimage">
in textarea.
So if the user writes specific keyword then
by using
str_replace, you can easily replace the specific keyword with
img src tag
and these images are displayed.
Related
I submitted some text to an SQL database like this:
"You can check my photo below (img src=..myimg.jpg..)and please also comment."
Now i want to retrieve it in PHP and containing image preview. The image code is HTML.
You need to escape data from DB before presenting it in page in order to what is stored doesn't mess with your page. But if you want also show the image, then you have to extract the img src part and put it back inside escaped output in proper html tag.
I am trying to have something like the image below in my PHP page.
(The links are in the comments. I was unable to post them here properly)
Once I enter the keyword and hit the "plus" it should appear in the table, along with the color to the right. The sequence of colors will be predetermined. If I enter a keyword again and hit the "plus" again, the keyword should appear just below the earlier keyword int the table. For the time being I am assuming the table consists of 5 rows and there are less than or equal to 5 keywords.
Also I want to have a submit button at the bottom that when clicked should send all the keywords now present to a PHP file. I have a form with the action attribute set to a PHP file. The table and the keyword input field are to be a part of a form.
I prefer using javascript and not PHP for many complications. Is there a way I can store all the keywords and then send it to the PHP file once the form is submitted?
Any help would be greatly appreciated.
You could:
Build the html form with five text inputs, all stacked on top of one
another (I think using position: absolute).
Place html table underneath inputs.
Place submit button underneath table.
Use javascript to:
hide the four text inputs that aren't currently being used
display the text input and corresponding color in the table when the user presses the +.
hide the current text input and show the next input when the user presses the +.
When user hits submit button, all five input values will be submitted to action='*.php'
Is there a way to display javascript variables and mysql values in a sort of label? As in say you have a letter template and there are spaces in the template where values from a database should be inserted but not in a text box. Here is a screenshot of what i am trying to explain :
The letter on the left is the template and the blue coloured text is where the database values need to be entered but in a format that would suit the letter template which will be printed and mailed out, so it couldn't be a text box, is there a way to display it in this manner?
Here is my current code :
Also is there a way to display that section of javascript in the same manner? Where it says [server date] in the template?
The main example would be Facebook Messages. On the "To:" field, you can type in one letter, then it will show a search result of your friends that matches that letter. Then once you choose that friend, you can add another friend, on that same input field.
Is there a function/script that allows you to add more than 1 data on the same input field?
Is there a function/script that allows
you to add more than 1 data on the
same input field?
Short answer, no.
If you look at the source code for the "To:" field, you realize Facebook isn't achieving this effect with only a text input.
This trick uses a div to mimic a text input, but also has a text input (with no border) within it to capture the text being typed. Once they a match is found in the search drop down, a 'token' is inserted into the div, and the text input is shifted over.
Weird to describe but here goes.
I have a table with several rows. One of the fields in each row, is for an image. Now i dont want to show the image itself, but rather the filename of the image as a link.
When i click that link, i want to popup a window that will let me upload or choose a new image from a list.
The key is, when im done, i want the new filename to show up on the table a-la inline edit style.
Now i know how to display the filename as a link, i know how to popup a window, i know how to upload images, or display some to select from. What i dont know how to do, is once i select or upload an image, to then go back and change that text.
Say the fieldname containing the filename text is #picfield1.(will be unique per field)
What would be the best way of building this. Should i use a layer on page like a modal, or should i use a seperate window?
When the popup is opened, you need to pass to it the row, or id, of the link that was clicked. Once the popup is done and prior to calling its window.close() function (if it's a real popup), have it do something like this:
window.opener.updateImageLink(row, fileName); //will call a function on the parent window
Where row is what was passed to this popup initially and filename is the effective filename with which to update the link.
This will call the following function:
function updateImageLink(row, fileName)
{
document.getElementById("#picfield" + row).innerHTML = escape(fileName);
}
This assumes that the fields are enumerated as #picField1, #picField2, etc. You may need to add one to row when making this call.
This needs to be tweaked, of course, based on your specific needs.