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:

<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>

Recommended Answers

All 2 Replies

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:

<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.

Member Avatar for langsor

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

<?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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.