For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > January 2008 > Re: [PHP-DB] New to PHP/MySQL - Need help with images









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] New to PHP/MySQL - Need help with images
Chris

2008-01-06, 7:00 pm

Thomas wrote:
> I'm attempting to make a table with one row and 3 columns holding three
> different images. I want each image URL to be called from my database.
> Everything is set-up in my database. When I use the following code, it
> places the same picture across the three columns and does this three
> times (creating three rows.) I want a different picture to be placed
> across the three columns and to have only one row. What can I do?


> Here is the code:
>
> $result = @mysql_query('SELECT image FROM specials');


You're only querying one database field here. If you want more than one
image to be loaded from the database, you need to include more fields.

So you'll end up with something like this:


<?php

$query = "select image1, image2, image3 from specials";
$result = mysql_query($query);

echo '<table>';

while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo '<td>' . $row['image1'] . '</td>';
echo '<td>' . $row['image2'] . '</td>';
echo '<td>' . $row['image3'] . '</td>';
echo '</tr>';
}
echo '</table>';
?>


--
Postgresql & php tutorials
http://www.designmagick.com/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com