jamesjmann Posted May 15, 2011 Share Posted May 15, 2011 Hi, I'm trying to make a dynamic html table to contain the mysql data that is generated via php. I'm trying to display a user's friends in a table of two columns and however many rows, but can't seem to figure out what is needed to make this work. Here's my code as it stands: <?php //Begin mysql query $sql = "SELECT * FROM friends WHERE username = '{$_GET['username']}' AND status = 'Active' ORDER BY friends_with ASC"; $result = mysql_query($sql); $count = mysql_num_rows($result); $sql_2 = "SELECT * FROM friends WHERE friends_with = '{$_GET['username']}' AND status = 'Active' ORDER BY username ASC"; $result_2 = mysql_query($sql_2); $count_2 = mysql_num_rows($result_2); while ($row = mysql_fetch_array($result)) { echo $row["friendswith"] . "<br>"; } while ($row_2 = mysql_fetch_array($result_2)) { echo $row_2["username"] . "<br>"; } ?> The above simply outputs all records of a user's friends (their usernames) in alphabetical order. The question of how I'd generate a new row each time a certain amount of columns have been met, however, is beyond me. Anyone know of any helpful resources that may solve my problem? Thanks in advance =) Link to comment https://forums.phpfreaks.com/topic/236467-generating-dynamic-html-table-while-displaying-mysql-data/ Share on other sites More sharing options...
wildteen88 Posted May 15, 2011 Share Posted May 15, 2011 Have a look at Multi Column Results within the Code Repository Link to comment https://forums.phpfreaks.com/topic/236467-generating-dynamic-html-table-while-displaying-mysql-data/#findComment-1215699 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.