Images in PHP

Reply

Join Date: May 2008
Posts: 3
Reputation: lolo1313 is an unknown quantity at this point 
Solved Threads: 0
lolo1313 lolo1313 is offline Offline
Newbie Poster

Images in PHP

 
0
  #1
Sep 3rd, 2008
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:

  1. <span style="font-family: Verdana">
  2. <a target="blank" href="docs/posterelementaryweb.pdf">
  3. Elementary Poster
  4. </a>
  5. <br></br>
  6. <span style="font-family: Verdana">
  7. <a target="blank" href="docs/postersecondaryweb.pdf">
  8. Secondary Poster
  9. </a>
Last edited by cscgal; Sep 3rd, 2008 at 4:02 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 15
Reputation: Andrew Hucks is an unknown quantity at this point 
Solved Threads: 1
Andrew Hucks Andrew Hucks is offline Offline
Newbie Poster

Re: Images in PHP

 
0
  #2
Sep 3rd, 2008
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:

  1. <html>
  2. <head>
  3. <title>Bleh</title>
  4. </head>
  5. <body>
  6. Ooglie Oo....
  7.  
  8. <?php
  9. 1.
  10. <span style="font-family: Verdana">
  11. 2.
  12. <a target="blank" href="docs/posterelementaryweb.pdf">
  13. 3.
  14. Elementary Poster
  15. 4.
  16. </a>
  17. 5.
  18. <br>
  19. ?>
  20. IMG HERE
  21. <?php
  22. </br>
  23. 6.
  24. <span style="font-family: Verdana">
  25. 7.
  26. <a target="blank" href="docs/postersecondaryweb.pdf">
  27. 8.
  28. Secondary Poster
  29. 9.
  30. </a>
  31. ?>
  32. </body>
  33. </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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 381
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 33
langsor langsor is offline Offline
Posting Whiz

Re: Images in PHP

 
0
  #3
Sep 4th, 2008
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
  1. <?php
  2. // get your image path here.
  3. $path = 'my_image.jpg';
  4. // or write your entire image tag here
  5. $img_tag = '<img src="'.$path.'" alt="some image" />';
  6. ?>
  7. <html>
  8. <head>
  9. <title>Image Example</title>
  10. </head>
  11. <body>
  12. <img src="<? print $path?>" alt="some image" />
  13. <? print $img_tag ?>
  14. </body>
  15. </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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC