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? Quote Link to comment 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"; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.