GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Mar-2006, 11:39
hazh hazh is offline
New Member
 
Join Date: Jan 2006
Posts: 1
hazh is on a distinguished road

How to display image with 3 records per row


Currently i have a problem on how to display 3 images in one row. Next, I will display for the next 3 records. Below is the example of the coding:-

PHP Code:

<table>
<tr><td><?php echo listrec["img1] ?></td>td><?php echo listrec["img2] ?></td>td><?php echo listrec["img3] ?></td></tr>
<tr>.....samething goes here for the next 3 records..</tr>
</table> 



Now, i just display an image per row as if we go thru the whole records, for example like this:-

PHP Code:

while ($listrec = mysql_fetch_array($result)){

..display record here..

} 



I hope you will get what i means.
Your help very appreciated.

Regards
Hazh
Last edited by LuciWiz : 03-Mar-2006 at 11:41. Reason: Please insert your Php code between [php] & [/php] tags
  #2  
Old 05-Mar-2006, 03:34
fallen_samurai fallen_samurai is offline
Awaiting Email Confirmation
 
Join Date: Oct 2005
Location: Wisconsin, USA
Posts: 29
fallen_samurai is on a distinguished road

Re: How to display image with 3 records per row


You have the right idea, but there are certain areas that need a little work to fix it up right. I'll give a few suggestions, although you weren't clear on what the exact problem is, I still found things to debug.

Original Code:
PHP Code:

<table>
<tr><td><?php echo listrec["img1] ?></td>td><?php echo listrec["img2] ?></td>td><?php echo listrec["img3] ?></td></tr>
<tr>.....samething goes here for the next 3 records..</tr>
</table> 



Should be:
PHP Code:

?>
<table> // you need to start the table before the while loop, or it messes it up.
<? // start the php for the while loop
while ($listrec = mysql_fetch_array($result)) {
?> // turn off the php so the PHP writes the HTML code faster without echo
<tr>
<td><? echo listrec['img1']; ?></td>
<td><? echo listrec['img2']; ?></td>
<td><? echo listrec['img3']; ?></td>
</tr>
<? // restart PHP to complete the while loop bracket
}
?> // end PHP
</table> // end the table outside of the loop to so no tags are out of place 


Most of your errors were simple and lay in syntax such as having double quotes or single quotes. For instace. listrec["img1] should have been listrec['img1']. You have to make sure that anything inside of an array (this being a mysql_fetch_array) needs to be surrounded by single quotes when in a PHP bracket. Also, doing <?php ?> isn't always necessary, you can simply do <? ?>, it is the same thing. That is more a guideline than a rule, but it makes things go smoother and faster, and shortens the code a bit.

I hope this helps a little!

EDIT: If for whatever reason you decide to copy any part of this code verbatim, be sure to remove the // remarks. ( "// end PHP" ) the little side note things. Some of those don't belong there and they are only for your guidance to help you out, remove them from the code if you use any line with it on there.
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
display problem in firefox and opera batrsau Web Design Forum 4 09-Dec-2005 04:18
display raw image in a frame htv22 MS Visual C++ / MFC Forum 0 18-Jul-2005 20:34
GIM gidedit - a fltk fluid resize project cable_guy_67 FLTK Forum 2 01-Jun-2005 16:00
Checking source codes of image, audio and video files onauc C Programming Language 5 26-Feb-2005 22:47
display image on tv monitor Hood Graphics Forum 0 04-May-2004 17:21

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:20.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.