PHP/MySQL display image

This is a discussion on PHP/MySQL display image within the PHP Language forums, part of the PHP Programming Forums category; I'm trying to display a list. Each item will have a headline and a image. I have figured out ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-25-2008
robert.s@att.net
 
Posts: n/a
Default PHP/MySQL display image

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);
}
?>
Reply With Quote
  #2 (permalink)  
Old 02-25-2008
Jerry Stuckle
 
Posts: n/a
Default Re: PHP/MySQL display image

robert.s@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.
jstucklex@attglobal.net
==================

Reply With Quote
  #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
  #4 (permalink)  
Old 02-25-2008
robert.s@att.net
 
Posts: n/a
Default Re: PHP/MySQL display image

On Feb 24, 11:36 pm, rober...@att.net wrote:
> 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/" />


Stop the press. I got it. I needed the specifiers %s
This works:

<?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';
$alt_val = 'image';
$imagepath = 'images/';
$image_src = $row ["Imagesml"];
echo "<h3><a href=\"$page?id=$id\">". $row['ClientName'] . '</a></
h3>';
printf('<img alt="%s" src="%s%s"/>', $alt_val, $imagepath,
$image_src);
}
?>
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:14 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0