View Single Post

  #3 (permalink)  
Old 02-25-2008
robert.s@att.net
 
Posts: n/a
Default Re: PHP/MySQL display image

On Feb 24, 11:15 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> rober...@att.net wrote:
> > I'm trying to display a list. Each item will have a headline and a
> > image. I have figured out how to pull the headline text from the
> > database and display it but I don't know how to display images. I know
> > how to do this in .NET but not PHP.
> > Functionality: When you click on a headline it will take you to a
> > detail page with the headline, paragraph and larger image. I have
> > figured out everything but the image display.

>
> > So for example I wanted to use this method: printf('<img alt="%s"
> > src="%s" />', $id, $imagepath);
> > Below is my code for the query and output. I'm getting the alt
> > information showing up but not the image. I'm definitely missing
> > something here. In the database under the column named Imagesml I have
> > the image file names. For example image1.jpg.

>
> > <?php
> > $result = @mysql_query('SELECT Clientid, ClientName, Imagesml FROM
> > clients ORDER BY Clientid DESC;');
> > if (!$result) {
> > exit('<p>Error performing query: ' . mysql_error() . '</p>');
> > }
> > while ($row = mysql_fetch_array($result)) {
> > $id = $row['Clientid'];
> > $page = 'clientdetails.php';
> > $imagepath = 'images/';
> > echo "<h3><a href=\"$page?id=$id\">". $row['ClientName'] . '</a></
> > h3>';
> > printf('<img alt="image" src="images/" />', $id, $imagepath);
> > }
> > ?>

>
> What do you see when you view the page source? What's in $s - and is it
> correct?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================


This is what I get when I view the source: <img alt="image"
src="images/" />
Reply With Quote