Page 1 of 1
Make a row with images
Posted: Thu Mar 19, 2009 10:23 am
by shafiq2626
helow
i want display 4 records like images in one row and then should be move next row again should be display 4 record then move next row.
pls help me
thanks
Re: Make a row with images
Posted: Thu Mar 19, 2009 10:59 am
by William
shafiq2626 wrote:helow
i want to get the records from database with while loop. and want to display 4 records like images in one row and then should be make next row in which also should be display 4 record then move next row.
pls help me
thanks
I doubt anyone here will write it out for you. If you'd like help please post what you have so far.
Re: Make a row with images
Posted: Thu Mar 19, 2009 11:29 am
by shafiq2626
Just Copy This Code
Code: Select all
<?php
[color=#FF0000]
$query = mysql_query("Select * from tbl_madanijadwal");
$i = 0;
while ($row = mysql_fetch_array($query))
{
if ($i % 4 == 0)
echo "<td>".$row["manues"]."</td>";
$i++; [/color]}
?>
Re: Make a row with images
Posted: Thu Mar 19, 2009 12:31 pm
by LanceEh
Have you tried using a count function?
Re: Make a row with images
Posted: Thu Mar 19, 2009 1:09 pm
by crazycoders
What i usually do for this is the following:
Code: Select all
$irecord = 0;
echo '<table><tr>';
while($record = mysql_fetch_assoc($records)){
if(($irecord % 4) == 0){
echo '</tr><tr>';
}
echo '<td>content</td>';
$irecord++;
}
echo '</tr></table>';
Edit: The problem with this is that it forgets empty cells in the last row which is not XHTML compliant and it creates an empty row at the beginning which is not XHTML compliant too.