| | |
Images in PHP
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 3
Reputation:
Solved Threads: 0
I am using Microsoft Visual Web developer for a site that was already created in PHP. I maintain the site, and have to add a .jpg image of a poster next to the PDF link of the poster for teacher's to download. I am not sure what code to use in PHP since I am not familiar with this and was wondering if anyone could help. Here is what I have so far and need to find a way to attach the jpg of the elementary poster and one of the secondary poster after PDF:
html Syntax (Toggle Plain Text)
<span style="font-family: Verdana"> <a target="blank" href="docs/posterelementaryweb.pdf"> Elementary Poster </a> <br></br> <span style="font-family: Verdana"> <a target="blank" href="docs/postersecondaryweb.pdf"> Secondary Poster </a>
Last edited by cscgal; Sep 3rd, 2008 at 4:02 pm. Reason: Added code tags
•
•
Join Date: Sep 2008
Posts: 15
Reputation:
Solved Threads: 1
Couldn't you create a variable?
Something like $image = image url; then just put that in the PHP code?
(I stink at PHP, but I'll try to help.)
I think to define it, it'd go something like $image= 'image ur'l;
Then, wherever you want the image to be, you'd put $image in your coding.
I'm not as sure as the below as I am with the above, but meh.
PHP can be embedded right into HTML, just save the file as a .php extension.
So, you should be able to do this:
(Not perfect, but do you get the idea?)
So, the images would be in HTML, and the existing PHP would stay in PHP. I think that would work, but I'm not sure. I'd test it on a different website (grab the files from the existing website, open a free website account [Freehostia would be my suggestion], and try it.
Also, just a note. You have <br></br> in the existing code. The linebreak doesn't need an end code, so <br /> would work fine. (That's xHTML, which is just HTML cleaned up and standardized
Anyways, I'm sure someone can help you much, much more.
Something like $image = image url; then just put that in the PHP code?
(I stink at PHP, but I'll try to help.)
I think to define it, it'd go something like $image= 'image ur'l;
Then, wherever you want the image to be, you'd put $image in your coding.
I'm not as sure as the below as I am with the above, but meh.
PHP can be embedded right into HTML, just save the file as a .php extension.
So, you should be able to do this:
html Syntax (Toggle Plain Text)
<html> <head> <title>Bleh</title> </head> <body> Ooglie Oo.... <?php 1. <span style="font-family: Verdana"> 2. <a target="blank" href="docs/posterelementaryweb.pdf"> 3. Elementary Poster 4. </a> 5. <br> ?> IMG HERE <?php </br> 6. <span style="font-family: Verdana"> 7. <a target="blank" href="docs/postersecondaryweb.pdf"> 8. Secondary Poster 9. </a> ?> </body> </html>
(Not perfect, but do you get the idea?)
So, the images would be in HTML, and the existing PHP would stay in PHP. I think that would work, but I'm not sure. I'd test it on a different website (grab the files from the existing website, open a free website account [Freehostia would be my suggestion], and try it.
Also, just a note. You have <br></br> in the existing code. The linebreak doesn't need an end code, so <br /> would work fine. (That's xHTML, which is just HTML cleaned up and standardized
Anyways, I'm sure someone can help you much, much more.
Last edited by Andrew Hucks; Sep 3rd, 2008 at 9:47 pm.
•
•
Join Date: Aug 2008
Posts: 381
Reputation:
Solved Threads: 33
Hi,
I can not help you with anything specific to Microsoft Visual Web Developer ... sorry. But Andrew Hucks has the right idea here.
The question is, where are the images and how are you going to know what one to insert where? Is this info in a database? Is this info stored somewhere? That's the first part of this, where do we find our images using PHP?
Since the images are not apparently known ahead of time, but depend on the results from some search or by who is logged in at the time ... and we have now found the path to our image file (above) ... we can insert the image via inline PHP tags into the plain html code.
It looks something like this
image_test.php
The above two examples produce the same image tags.
If you specify your situation more we can probably help you in more depth.
Cheers
I can not help you with anything specific to Microsoft Visual Web Developer ... sorry. But Andrew Hucks has the right idea here.
The question is, where are the images and how are you going to know what one to insert where? Is this info in a database? Is this info stored somewhere? That's the first part of this, where do we find our images using PHP?
Since the images are not apparently known ahead of time, but depend on the results from some search or by who is logged in at the time ... and we have now found the path to our image file (above) ... we can insert the image via inline PHP tags into the plain html code.
It looks something like this
image_test.php
PHP Syntax (Toggle Plain Text)
<?php // get your image path here. $path = 'my_image.jpg'; // or write your entire image tag here $img_tag = '<img src="'.$path.'" alt="some image" />'; ?> <html> <head> <title>Image Example</title> </head> <body> <img src="<? print $path?>" alt="some image" /> <? print $img_tag ?> </body> </html>
The above two examples produce the same image tags.
If you specify your situation more we can probably help you in more depth.
Cheers
Google is the answer to all of your questions -- the trick is knowing what question to ask in your specific predicament.
![]() |
Similar Threads
- About image mirroring using php (PHP)
- is it possible to capture images using php (PHP)
- displaying mediumblob images using php (PHP)
- PHP downloading? (PHP)
- php read text scanned from other text editor (PHP)
- php url code? (PHP)
- Php Mysql Image Question (PHP)
- Shrink images (PHP)
- Redirecting images depending on the page they are displayed on. (Linux Servers and Apache)
Other Threads in the PHP Forum
- Previous Thread: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
- Next Thread: php help
| Thread Tools | Search this Thread |
# 5.2.10 action address apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date dehasher destroy display dissertation domain dynamic echo echo$_get[x]changingitintovariable... email error errorlog fatalerror file files folder form forms function functions google href htaccess html if-else image images include insert ip javascript joomla legislation limit link load login mail masterthesis menu mlm multiple mysql mysqlquery oop open paypal pdf persist php popup problem query radio random record recursion remote script search server sessions sms sockets source space sql syntax system table tutorial update upload url validator variable video web youtube





