Jump to content

[SOLVED] 2 database entries per table row


EvilVamp

Recommended Posts

Hi there!

 

I'm doing a redesign to my website but I'm having trouble designing a table.  Basically, I want this kind of structure:

 

________________

|            |          |

| Entry 1 | Entry 2 |

|_______|________|

|          |            |

| Entry 3 | Entry 4 |

|_______|________|

|            |          |

| Entry 5 | Entry 6 |

|_______|________|

 

Its a databse with game info in it, So I'd be putting an image, a paragraph and a link in each 'entry cell', thats the easy bit, but its getting two entries on a row that I'm stuck on.  This is a link to the design so far: http://gamer.awardspace.co.uk/index3.php its the 'capsules' under 'recently added games' that I want to put the info into.  Each capsule being a different game.

 

I hope this makes sense! Any help is appreciated! Thanks!

Link to comment
Share on other sites

This code worked great for me. You can set the # of columns as well. I used it to display 2 columns of subcategories in table cells pulling from the MySQL database.

 

// run query
$sql = "SELECT * FROM subcategories WHERE cat_id='2'";
$results = mysql_query($sql) or die(mysql_error());
// display results
$totalColumns = 2;
$i = 1;
echo "<table border='0' cellpadding='2'>";
while ($row = mysql_fetch_array($results)){
if ($i == 1) echo "<tr>";
echo "<td>";
echo "<a href='getcat.php?subcat_id=". $row['subcat_id'] . "'>" . $row['subcat_name'] . "</a>";
echo "</td>";
if ($i == $totalColumns)
	{
	echo "</tr>";
	$i = 0;
	}
$i++;
}
echo "</table>";

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.