{"id":637,"date":"2021-11-14T20:58:29","date_gmt":"2021-11-15T01:58:29","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=637"},"modified":"2024-02-08T08:44:27","modified_gmt":"2024-02-08T13:44:27","slug":"how-to-list-mysql-tables-using-php","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/how-to-list-mysql-tables-using-php\/","title":{"rendered":"How to list MySQL tables using PHP"},"content":{"rendered":"\n<p>The following code lists all tables in a MySQL database:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql_connect(\"localhost\",\"user\",\"pass\") or die(mysql_error());\nmysql_select_db(\"database\") or die(mysql_error());\n\n$rs = mysql_query(\"show tables\") or die(mysql_error());  \nwhile($row = mysql_fetch_array( $result )) { \n  print '&lt;br&gt;' .  $row&#91;0]; \n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The following code lists all tables in a MySQL database:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,204],"tags":[],"class_list":["post-637","post","type-post","status-publish","format-standard","hentry","category-database","category-mysql"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/637","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=637"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/637\/revisions"}],"predecessor-version":[{"id":638,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/637\/revisions\/638"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}