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

2008-01-06 Thread Chris

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:


';

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


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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2008-01-05 Thread Matt Anderton
how about like this:

echo "\n";
$result = @mysql_query("SELECT image FROM specials");
while($row = mysql_fetch_row($result)) {
   echo "\n";
}
echo "\n\n";

hope it helps!
matt

On Jan 5, 2008 4:51 PM, Thomas <[EMAIL PROTECTED]> 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');
> $num=mysql_numrows($result);
> $i = 0;
> while ($i < $num) {
> $image=mysql_result($result,$i,"image");
> ?>
> 
> 
> 
> ">
> 
> 
> ">
> 
> 
> ">
> 
> 
>  $i++;
> }
> echo "";
> ?>
>
> --
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP-DB] New to PHP/MySQL - Need help with images

2008-01-05 Thread Thomas
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');
$num=mysql_numrows($result);
$i = 0;
while ($i < $num) {
$image=mysql_result($result,$i,"image");
?>



">


">


">


";
?>

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php