{"id":186,"date":"2010-12-22T23:11:02","date_gmt":"2010-12-22T20:11:02","guid":{"rendered":"http:\/\/itist.ru\/blog\/?p=186"},"modified":"2018-08-01T23:11:59","modified_gmt":"2018-08-01T20:11:59","slug":"kak-vybrat-dannye-iz-bd-mysql-v-spisok-na-php","status":"publish","type":"post","link":"http:\/\/itist.ru\/blog\/?p=186","title":{"rendered":"\u041a\u0430\u043a \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0411\u0414 MySQL \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430 PHP"},"content":{"rendered":"<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438 \u0430\u0439\u0442\u0438\u0441\u0442\u0430! =)<\/p>\n<p>\u0411\u044b\u043b\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u043c\u0435\u043d\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0439 \u0431\u044b\u043b\u043e \u043c\u0430\u043b\u043e.<\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u0443\u044e \u0442\u0435\u043c\u0443 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0439 \u043f\u043e\u043c\u043e\u0435\u043c\u0443 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u0431\u044b\u043b\u043e, \u0438 \u044f \u043d\u0435 \u043e\u0441\u0432\u044f\u0437\u0430\u043b \u043d\u0430 \u044d\u0442\u043e\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0435 \u043a\u0430\u043a\u0438\u0435 \u043b\u0438\u0431\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 PHP, \u043d\u043e \u0432\u0441\u0451 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043f\u0435\u0440\u0432\u044b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0442 \u0432\u0430\u043c \u043a\u043e\u0434\u044b, \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0435 =)<br \/>\n\u041f\u0435\u0440\u0435\u0434 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043a \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044e <a href=\"https:\/\/itist.ru\/blog\/?p=295\">\u0421\u043f\u0438\u0441\u043a\u0438 \u0432 HTML<\/a><\/p>\n<p>\u0418 \u0442\u0430\u043a, \u0442\u0430\u043a\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430:<\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (MySQL) \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u0441 \u0442\u0435\u043c\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u043e\u0440\u043c\u0443, \u0438 \u0432 \u043d\u0435\u0439 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0411\u0414 \u0431\u044b\u043b\u0438<strong> \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 config.php<\/strong><\/p>\n<p><strong>\u0412\u043e\u0442 \u0435\u0451 \u043a\u043e\u0434:<\/strong><\/p>\n<blockquote>\n<p>&lt;?PHP$dbhost=&#8217;localhost&#8217;;<br \/>\n$dbname=&#8217;salon&#8217;;<br \/>\n$dbpass=&#187;;<br \/>\n$dblogin=&#8217;root&#8217;;<\/p>\n<p>?&gt;<\/p>\n<\/blockquote>\n<p>\u0418 \u0442\u0430\u043a, \u0432\u043e\u0442 \u0432\u0430\u043c \u043a\u043e\u0434 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0438 page.php, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a:<span id=\"more-292\"><\/span><\/p>\n<blockquote>\n<p>&lt;?<br \/>\necho&#187;<br \/>\n&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;title&gt;\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0437\u0430\u043a\u0430\u0437\u0430 \u0432 \u0441\u0430\u043b\u043e\u043d\u0435&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;center&gt;&#187;;\/\/\u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0445 \u0432\u044b<br \/>\n\/\/\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 users, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0439 \u043f\u043e\u043b\u044f id, login, pass<br \/>\ninclude &#8216;config.php&#8217;;<\/p>\n<p>$db=mysql_connect($dbhost, $dblogin, $dbpass)<br \/>\nor die(&#171;\u041d\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f&#187;);<\/p>\n<p>mysql_select_db($dbname, $db)<br \/>\nor die(&#171;\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u044f \u043a \u0411\u0414.&#187;);<\/p>\n<p>echo (&#171;&lt;form action=exec.php method=post&gt;&#187;);<\/p>\n<p>$sql=mysql_query(&#171;select * from uslugi&#187;);<br \/>\n$kolstr=mysql_num_rows($sql);<br \/>\necho (&#171;\u0421\u043f\u0438\u0441\u043e\u043a \u0443\u0441\u043b\u0443\u0433:&lt;br&gt;&#187;);<br \/>\necho (&#171;&lt;select name=usluga maxlength=24 size=1 &gt; &#171;);<br \/>\n$var=mysql_fetch_array($sql);<br \/>\n$i = 0;<br \/>\nwhile ($i &lt; $kolstr){<br \/>\n$var = mysql_fetch_array($sql);<br \/>\necho(&#8216;&lt;option value=&#8217;.$var[&#8216;Kod_uslugi&#8217;].&#8217;&gt;&#8217;.$var[&#8216;Naimenovanie&#8217;].'&lt;\/option&gt;&#8217;);<br \/>\n$i++;<br \/>\n}<br \/>\necho (&#171;&lt;\/select&gt;&lt;br&gt;&#187;);<\/p>\n<p>echo (&#171;&lt;input type=submit name=send value=\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c&gt;&lt;\/form&gt;&#187;);<br \/>\necho&#187;<br \/>\n&lt;\/center&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<br \/>\n&#171;;<br \/>\n?&gt;<\/p>\n<\/blockquote>\n<p>\u043a\u0430\u043a \u0432\u044b \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 exec.php, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435.<\/p>\n<blockquote>\n<p>&lt;?<\/p>\n<p>$id_uslugi = $_POST[&#8216;usluga&#8217;];<br \/>\necho (&#171;$id_uslugi&#187;);<\/p>\n<p>?&gt;<\/p>\n<\/blockquote>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043f\u043e\u043c\u043e\u0433 \u0432\u0430\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043d\u0438\u0445 \u0438\u0437 \u0411\u0414.<br \/>\n\u0415\u0441\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438\u043b\u0438 \u043d\u0430 \u043c\u044b\u043b\u043e, \u0438 \u044f \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043f\u043e\u043c\u043e\u0447\u044c \u0441 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c ??<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438 \u0430\u0439\u0442\u0438\u0441\u0442\u0430! =) \u0411\u044b\u043b\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u043c\u0435\u043d\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0439 \u0431\u044b\u043b\u043e \u043c\u0430\u043b\u043e. \u041d\u0430 \u0434\u0430\u043d\u043d\u0443\u044e \u0442\u0435\u043c\u0443 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0439 \u043f\u043e\u043c\u043e\u0435\u043c\u0443 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u0431\u044b\u043b\u043e, \u0438 \u044f \u043d\u0435 \u043e\u0441\u0432\u044f\u0437\u0430\u043b \u043d\u0430 \u044d\u0442\u043e\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0435 \u043a\u0430\u043a\u0438\u0435 \u043b\u0438\u0431\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 PHP, \u043d\u043e \u0432\u0441\u0451 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043f\u0435\u0440\u0432\u044b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0442 \u0432\u0430\u043c \u043a\u043e\u0434\u044b, \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0435 =) \u041f\u0435\u0440\u0435\u0434 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/itist.ru\/blog\/index.php?rest_route=\/wp\/v2\/posts\/186"}],"collection":[{"href":"http:\/\/itist.ru\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/itist.ru\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/itist.ru\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/itist.ru\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=186"}],"version-history":[{"count":2,"href":"http:\/\/itist.ru\/blog\/index.php?rest_route=\/wp\/v2\/posts\/186\/revisions"}],"predecessor-version":[{"id":325,"href":"http:\/\/itist.ru\/blog\/index.php?rest_route=\/wp\/v2\/posts\/186\/revisions\/325"}],"wp:attachment":[{"href":"http:\/\/itist.ru\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/itist.ru\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/itist.ru\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}