Jump to content

Results in column layout not table


zimmo

Recommended Posts

I have been trying to work out how to get my results into a 3 column layout using css and not using tables in any way.

 

I found the code for tables:

			echo '<table>'; 

			$counter = 0; 
			$cells_per_row = 3; 
			while($row=mysql_fetch_array($result)) 
			{ 
			    $counter++; 
			    if(($counter % $cells_per_row) == 1)  { echo '<tr>'; } 
			    echo '<td>' . (whatever you echo from your $row array) . '</td>'; 
			    if(($counter %  $cells_per_row) == 0) { echo '</tr>'; } 
			} 
			// just in case we haven't closed the last row 
			// this would happen if our result set isn't divisible by $cells_per_row 
			if(($counter % $cells_per_row) != 0) { echo '</tr>'; } 

			echo '</table>'; 

 

How Can I adapt this or how should I use divs here?

I am fine with the css code, just need to work out how to get the 3 column layout correct in the loop.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.