hane Posted March 5, 2009 Share Posted March 5, 2009 Attached is an eg. of how I want to display info that i get from my mysql database. If you can just point me in the right direction I would really appreciated it. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/148059-solved-php-table-help-please/ Share on other sites More sharing options...
ILMV Posted March 5, 2009 Share Posted March 5, 2009 What? You need to be a thousand times more specific... Are you returning a list of image URLs you want displaying in that format? Also, this is in the wrong forum... Edit: Sorry It is int he correct forum Link to comment https://forums.phpfreaks.com/topic/148059-solved-php-table-help-please/#findComment-777135 Share on other sites More sharing options...
gevans Posted March 5, 2009 Share Posted March 5, 2009 What do you have so far, it's easier to work with your existing code than to write it out in full, plus you'll learn more that way Link to comment https://forums.phpfreaks.com/topic/148059-solved-php-table-help-please/#findComment-777138 Share on other sites More sharing options...
hane Posted March 5, 2009 Author Share Posted March 5, 2009 I've got it here is the code <?php //set the number of columns $columns = 3; $query = "SELECT * FROM africanskyjewellery_items"; $result = mysql_query($query); //we add this line because we need to know the number of rows $num_rows = mysql_num_rows($result); echo "<table summary='' border='0' width='100%'>\n"; //changed this to a for loop so we can use the number of rows for($i = 0; $i < $num_rows; $i++) { $row = mysql_fetch_array($result); if($i % $columns == 0) { //if there is no remainder, we want to start a new row echo "<tr>\n"; } echo "<td colspan='2'>"; echo "<img src='images/" . $row['africanskyjewellery_items_ref'] . ".jpg' width='150'></a><br />"; echo "<b>Ref:</b>". $row['africanskyjewellery_items_ref'] ."<br />"; echo "<b>Price:</b>R" . $row['africanskyjewellery_items_price'] . "<br />"; echo "</td>\n"; if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows) { //if there is a remainder of 1, end the row //or if there is nothing left in our result set, end the row echo "</tr>\n"; } } echo "</table>\n"; ?> Link to comment https://forums.phpfreaks.com/topic/148059-solved-php-table-help-please/#findComment-777140 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.