Make a row with images

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shafiq2626
Forum Commoner
Posts: 88
Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:

Make a row with images

Post 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
Last edited by shafiq2626 on Thu Mar 19, 2009 11:31 am, edited 1 time in total.
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

Re: Make a row with images

Post 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.
shafiq2626
Forum Commoner
Posts: 88
Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:

Re: Make a row with images

Post 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]}
?>
User avatar
LanceEh
Forum Commoner
Posts: 46
Joined: Tue Feb 17, 2009 11:53 am
Location: Florida

Re: Make a row with images

Post by LanceEh »

Have you tried using a count function?
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: Make a row with images

Post 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.
Post Reply