|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
problem with img src and php
I am able to display row to call image from file, but I want to enclose the html call (img src) in php so I can run an if statement. Now, if there is no image, the field is empty on the page, displays a ?. But, I want to run an if statement to check first, then print the img src. , if not, print "".
Here is the script to just print the image anyway. I am happy with the way the size feature works. The database has a field for tall or wide from radio button. It has a set size, but it will display it as tall or wide. Little gains. PHP Code:
Later I'd like to give user the option to size it with form, but this is easy for now. One more question, I used the following code to create the radio buttons and it is not returning the button as marked when I edit a record... any ideas? PHP Code:
Thanks everyone for all the help.
__________________
bow wow! |
|
#2
|
||||
|
||||
|
Before you print anything (or display the beginning of the img tag outside PHP), you need to check to see if the image field has a value. If it does, then start printing the image and building up the parameters. Else, just keep on trucking without printing anything.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
Yes, but..
Thank you for your help dh, but I don't get how to skip the img html tag with php, since the img src tag is html. It it was enclosed in php then I could see how to if else it.
I'll keep playing with it. Thanks again. What I'm trying to learn is how to make the <img src> tag a variable with php, but when I write to put in $img1 = "<img src ... etc. then it doesn't work. I'm missing a / or . or ./" , I'm still trying to learn that part. R. |
|
#4
|
||||
|
||||
|
What I'm suggesting is that you move it into PHP rather than having it be in HTML. Just move the "<img src='uploads/" inside the PHP block and print it out. Same with the end of the tag. If you're missing a /, just add one in the print statement where it's missing. If you put the img tag in the HTML, then the HTML's always going to try to display an image; the only way to test for an image before displaying it is to move the whole image tag inside a conditional statement in PHP.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > problem with img src and php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|