jamesjmann Posted February 4, 2011 Share Posted February 4, 2011 When displaying data from a mysql table, what php code can I use to display the number of columns in said table? Like, say I'm displaying comments by users. I want to be able to put "displaying 'thismany' comments". Any suggestions? Link to comment https://forums.phpfreaks.com/topic/226643-display-number-of-columns-in-table/ Share on other sites More sharing options...
jamesjmann Posted February 4, 2011 Author Share Posted February 4, 2011 NVM. Just googled it and came up with this: <?php $link = mysql_connect("hostname", "username", "password"); mysql_select_db("database", $link); $result = mysql_query("SELECT * FROM table ", $link); $num_rows = mysql_num_rows($result); echo "$num_rows Comments"; ?> Link to comment https://forums.phpfreaks.com/topic/226643-display-number-of-columns-in-table/#findComment-1169726 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.