|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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); } ?> |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 ================== |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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/" /> |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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); } ?> |
|
![]() |
| Outils de la discussion | |
|
|