Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-05-2008, 05:55 PM Help with images
Average Talker

Posts: 23
Name: Thomas
Location: Alberta, Canada
Trades: 0
I'm attempting to make a table with one row and 3 columns (holding three different pictures in all.) I want each picture URL to be called from 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");
?>
<table>
<tr>
<td>
<img src="<? echo "$image"; ?>">
</td>
<td>
<img src="<? echo "$image"; ?>">
</td>
<td>
<img src="<? echo "$image"; ?>">
</td>
</tr>
<?
$i++;
}
echo "</table>";
?>
thomashw is offline
Reply With Quote
View Public Profile Visit thomashw's homepage!
 
 
Register now for full access!
Old 01-05-2008, 07:49 PM Re: Help with images
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
You only want the
Code:
<td> <img src="<?php echo $image; ?>"></td>
in your loop, the rest should be outside of the loop.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 01-06-2008, 04:30 AM Re: Help with images
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
To summarise above:
Code:
$result = @mysql_query('SELECT image FROM specials');
$num=mysql_numrows($result);
$i = 0;
?>
<table>
<tr>
while ($i < $num) {
 $image=mysql_result($result,$i,"image");
echo "<td>
<img src=\"$image\">
</td>";
$i++;
 }
</tr>
</table>
plus mysql_numrows is deprecated - you'd be better off changing it to mysql_num_rows which isn't.
__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Reply     « Reply to Help with images
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14182 seconds with 12 queries