PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > PHP/MySQL display image
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
PHP/MySQL display image

Réponse
 
LinkBack Outils de la discussion
Vieux 25/02/2008, 04h09   #1
robert.s@att.net
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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);
}
?>
  Réponse avec citation
Vieux 25/02/2008, 04h15   #2
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
==================

  Réponse avec citation
Vieux 25/02/2008, 04h36   #3
robert.s@att.net
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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/" />
  Réponse avec citation
Vieux 25/02/2008, 05h59   #4
robert.s@att.net
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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);
}
?>
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 16h57.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16610 seconds with 12 queries