Forum Moderators: coopster

Message Too Old, No Replies

Need Help for while loop

         

Shanee

5:35 am on Oct 26, 2007 (gmt 0)

10+ Year Member



Hello to all,
i have coded simple myql statment and loop for my upcoming wallpapers site. which is below

php Code:
<?php $sql = "select wallpaperid, title, date, rating from wallpaper order by downloads desc limit 0,10"; $result = mysql_query($sql ,$db); if ($myrow = mysql_fetch_array($result)) { do { if ($rowcolor == 1) { printf("<table width='200px' cellspacing='0' cellpadding='0'> <tr> <td><img src='%s'/></td> </tr></table>", $myrow["wallpaperid"]); } while ($myrow = mysql_fetch_array($result)); } ?>

its output is
Image1
Image2
Image3
Image4
Image5
Image6
blah blah......

can anyone tell me how i can get the below output

Image1 Image2 Image3

Image4 Image5 Image6

vincevincevince

5:41 am on Oct 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why not output them all into one big <div> of a fixed width; and ensure that the widths of each component are 1/3rd of the DIV's width.

That way you won't be needlessly using tables for layout; you will save yourself code; and it will be easier to reflow your content for mobile devices.

Shanee

4:29 pm on Oct 26, 2007 (gmt 0)

10+ Year Member



Dear vincevincevince
i am still little confuse. can you give me example?

thanks

vincevincevince

5:03 pm on Oct 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<div style="width:200px">

<img src="image.jpg" style="width:66px">
<img src="image.jpg" style="width:66px">
<img src="image.jpg" style="width:66px">
<img src="image.jpg" style="width:66px">
<img src="image.jpg" style="width:66px">
<img src="image.jpg" style="width:66px">
<img src="image.jpg" style="width:66px">
<img src="image.jpg" style="width:66px">
<img src="image.jpg" style="width:66px">

</div>

Shanee

2:14 pm on Oct 27, 2007 (gmt 0)

10+ Year Member



wow... it is working perfectly.
but i want to add some caption to every thumb. thats why DIV is not working for me here.

means still i am strucking on the old spot :(

[edited by: Shanee at 2:15 pm (utc) on Oct. 27, 2007]

cameraman

8:20 pm on Oct 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Take a look at this thread [webmasterworld.com].

vincevincevince

7:06 am on Oct 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<div style="width:200px">

<div style="float:left;width:66px><img src="image.jpg"><br>Caption</div>
<div style="float:left;width:66px><img src="image.jpg"><br>Caption</div>
<div style="float:left;width:66px><img src="image.jpg"><br>Caption</div>

<div style="float:left;width:66px><img src="image.jpg"><br>Caption</div>
<div style="float:left;width:66px><img src="image.jpg"><br>Caption</div>
<div style="float:left;width:66px><img src="image.jpg"><br>Caption</div>

</div>