EvilVamp Posted October 19, 2007 Share Posted October 19, 2007 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 https://forums.phpfreaks.com/topic/73999-solved-2-database-entries-per-table-row/ Share on other sites More sharing options...
simcoweb Posted October 19, 2007 Share Posted October 19, 2007 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 https://forums.phpfreaks.com/topic/73999-solved-2-database-entries-per-table-row/#findComment-373548 Share on other sites More sharing options...
EvilVamp Posted October 19, 2007 Author Share Posted October 19, 2007 Great thanks! It looks so simple hehe I'll try it now. Link to comment https://forums.phpfreaks.com/topic/73999-solved-2-database-entries-per-table-row/#findComment-373551 Share on other sites More sharing options...
EvilVamp Posted October 19, 2007 Author Share Posted October 19, 2007 It works prefectly! Thanks very much Link to comment https://forums.phpfreaks.com/topic/73999-solved-2-database-entries-per-table-row/#findComment-373566 Share on other sites More sharing options...
simcoweb Posted October 19, 2007 Share Posted October 19, 2007 Of course it works! Link to comment https://forums.phpfreaks.com/topic/73999-solved-2-database-entries-per-table-row/#findComment-373583 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.