{"id":340,"date":"2013-04-29T11:15:15","date_gmt":"2013-04-29T11:15:15","guid":{"rendered":"https:\/\/shan.info\/new\/php-foreach-select\/"},"modified":"2013-04-29T11:15:15","modified_gmt":"2013-04-29T11:15:15","slug":"php-foreach-select","status":"publish","type":"post","link":"https:\/\/shan.info\/new\/php-foreach-select\/","title":{"rendered":"php \u8868\u683c foreach \u663e\u793a select \u7ed3\u679c"},"content":{"rendered":"<pre class=\"brush:php\">&lt;?php\r\n$con = mysql_connect(\"localhost\",\"tdg\",\"tdg\");\r\nif (!$con)\r\n  {\r\n  die('Could not connect: ' . mysql_error());\r\n  }\r\n\r\nmysql_select_db(\"tdg\", $con);\r\n\r\n$result = mysql_query(\"SELECT * FROM  `client`\");\r\n?&gt;\r\n\r\n&lt;table border=\"2\"&gt;\r\n    &lt;?php while ($row = mysql_fetch_assoc($result)): ?&gt;\r\n    &lt;tr&gt;\r\n        &lt;?php foreach($row as $key=&gt;$value) {   \r\n            echo \"&lt;td&gt;$key: $value&lt;\/td&gt;n \"; \r\n        } ?&gt; \r\n    &lt;\/tr&gt;          \r\n    &lt;?php endwhile; ?&gt;\r\n&lt;\/table&gt;\r\n&lt;?php\r\nmysql_close($con);\r\n?&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&lt;?php $con = mysql_connect(&#8220;localhost&#8221;,&#8221;tdg&#8221;,&#8221;tdg&#8221;); if (!$con) { die(&#8216;Could not connect: &#8216; . mysql_error()); } mysql_select_db(&#8220;tdg&#8221;, $con); $result = mysql_query(&#8220;SELECT * FROM `client`&#8221;); ?&gt; &lt;table border=&#8221;2&#8243;&gt; &lt;?php while ($row = mysql_fetch_assoc($result)): ?&gt; &lt;tr&gt; &lt;?php foreach($row as $key=&gt;$value) { echo &#8220;&lt;td&gt;$key: $value&lt;\/td&gt;n &#8220;; } ?&gt; &lt;\/tr&gt; &lt;?php endwhile; ?&gt; &lt;\/table&gt; &lt;?php mysql_close($con); ?&gt;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[],"class_list":["post-340","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts\/340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/comments?post=340"}],"version-history":[{"count":0,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts\/340\/revisions"}],"wp:attachment":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/media?parent=340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/categories?post=340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/tags?post=340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}