anonymouse Posted October 28, 2009 Share Posted October 28, 2009 Good day! I'm a beginner in PHP and I'm not expecting a full coding for this qestion. I'm just looking for hints and pointers as to how to solve this problem so that I can learn it myself. I have a question here about displaying data from database into a 2 dimensional table. Say I have a 2 dimensional table something like below And I have a data in the database that corresponds to something like R1C3 and R2C1, how do I display the data on the table so that it looks something like below Any help would be greatly appreciate. Thanks and have a nice day Link to comment https://forums.phpfreaks.com/topic/179336-displaying-data-from-database-into-a-2-dimensional-table/ Share on other sites More sharing options...
seanlim Posted October 28, 2009 Share Posted October 28, 2009 I would recommend that you use a 2D array in PHP to store the value of the cells before printing out the entire table.. In your example, the code would be something along the lines of ... $table[1][3] = "Data"; $table[2][1] = "Data"; ... Then, to output the code into a table: foreach($table as $row){ echo "<tr>"; foreach($row as $cell){ echo "<td>".$cell."</td>"; } echo "</tr>"; } HTH Link to comment https://forums.phpfreaks.com/topic/179336-displaying-data-from-database-into-a-2-dimensional-table/#findComment-946236 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.