Jump to content

Need help, PHP and Tables


gfX

Recommended Posts

Hello.

What I am trying to do, is have 12 total layouts showing.  3 rows of 4.

I am using tables for this, and it is generated using PHP.

 

	<table border="0" cellspacing="0" cellpadding="1" align="center">
		<?php
		        $sql = mysql_query("SELECT * FROM `layouts` ORDER BY `id` ASC");
				$i = 0;
        while ($r=mysql_fetch_assoc($sql)) 
            {
                $i++;
	$id = $r['id'];
                $title = $r['title'];
                $code = $r['code'];
                $thumbnail = $r['thumbnail'];
			if (($i == 5))
				{
					echo "<tr>";
				}
                echo "<td width='25%' align='center' valign='top'>
			<a href='http://www.layoutslife.com/code.php?id=$id'>
			<img src='http://www.layoutslife.com/thumbnails/$thumbnail' border='0' width='160' height='120' /></a>
			<br /><b>$title</b><br /></td>";
			if (($i == 5))
				{
					echo "</tr>";
				}

            
		}
    
    ?>


	</table>

 

That's the code I have, which I know is definitely wrong because it isn't working! Does anyone know how I can get this done?

Here is a screenshot of how it displays with my current code:

 

problemEa5k.gif

 

Thanks

 

 

Link to comment
Share on other sites

Soooooo..

 

	<table border="0" cellspacing="0" cellpadding="1" align="center">
	<tr>
		<?php
		        $sql = mysql_query("SELECT * FROM `layouts` ORDER BY `id` ASC");
				$i = 0;
        while ($r=mysql_fetch_assoc($sql)) 
            {
                $i++;
	$id = $r['id'];
                $title = $r['title'];
                $code = $r['code'];
                $thumbnail = $r['thumbnail'];
			if ($i > 0 && $i % 5 == 0) {
  				print "</tr><tr>";
}
                echo "<td width='25%' align='center' valign='top'>
			<a href='http://www.layoutslife.com/code.php?id=$id'>
			<img src='http://www.layoutslife.com/thumbnails/$thumbnail' border='0' width='160' height='120' /></a>
			<br /><b>$title</b><br /></td>";


            
		}
    
    ?>

		</tr>
	</table>

 

?? Almost there, Preview at: www.layoutslife.com

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.