--- On Tue, 9/23/08, zarilahr <[EMAIL PROTECTED]> wrote: > i stored images in mysql as varchar. i want to display them > in php as horizotnally. The code is as bewlo which i used but it > is showing all the images horizontaly i want to break them with the > number of 2 i mean per row only 2 images should be placed. > > <table width="100%" border="1" > cellspacing="0" cellpadding="0"> > <tr> > <table width="26%" border="1" > cellspacing="0" cellpadding="0"> > <tr> > > <?php > > $i=0; > $q = mysql_query ("select * from stuff where cat_id = > '1' > and prod_featured = 'yes'"); > while ($r = mysql_fetch_array ($q)) > { > if ($i==3) > { > $i=0; > > } > $i+=1; > ?> > <td><?php echo > $r["image_name"]?></td> > <td><img src="images/<? echo > $r["image_path"]?>" /></td> > > > <?php > } > ?> > </tr> > > > > > </table> > </tr> > > </tr> > </table> > > Please help me > Regards > Azhar
First, storing image data in the table is a bad idea. However, looking at your code, it appears that you are not doing this but are storing the file name of each image. This is the preferred method. It sounds like you want some kind of break every two images. What you will probably want to do is perform some kind of count after each image is displayed and conditionally add either a <br> or a </td></tr><tr><td> after every two images are displayed. This is a simple demonstration for the command line. Change the \t and \n (tab and newline) for a web illustration. # initialize variables $row = 1; $n = 1; # loop through each number from 1 to 100 foreach (range(1,100) as $n) { # display the number (or image) print "$n\t"; # conditionally add some form of line break print ($row++ %2) ? "" : "\n"; } James Keeline