chrisuk Posted November 5, 2007 Share Posted November 5, 2007 How do I do this? Usually I have a table and a while loop and do the standard procedure to make the table. However that's vertical - how can i do it for horizontal purposes? Link to comment https://forums.phpfreaks.com/topic/76074-dynamic-tables-that-go-horizontally-instead-of-vertically/ Share on other sites More sharing options...
Psycho Posted November 5, 2007 Share Posted November 5, 2007 Well, you didn't eally provide much details, but it's very simple: <?php echo "<table>\n"; echo "<tr>\n"; while ($record = mysql_fetch_assoc($result)) { echo "<td>" . $record['indexName'] . "</td>\n"; } echo "</tr>\n"; echo "</table>\n"; ?> Link to comment https://forums.phpfreaks.com/topic/76074-dynamic-tables-that-go-horizontally-instead-of-vertically/#findComment-385092 Share on other sites More sharing options...
cooldude832 Posted November 5, 2007 Share Posted November 5, 2007 you can't easily do it in the while loop of a while($row = mysql_fetch); what needs to happen is you store the data from this loop in the loop then build the table in a secondary loop <?php while($row = mysql_fetch_array($result)){ foreach($row as $key => $value){ $data[$key][] = $value; } //then build your data off this multi-dimenosonal array Link to comment https://forums.phpfreaks.com/topic/76074-dynamic-tables-that-go-horizontally-instead-of-vertically/#findComment-385093 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.