{"id":253204,"date":"2017-07-06T22:55:14","date_gmt":"2017-07-06T22:55:14","guid":{"rendered":"https:\/\/ru.wordpress.org\/support\/topic\/phpjquery-%d0%bf%d1%80%d0%be%d0%b1%d0%bb%d0%b5%d0%bc%d0%b0-%d1%81-%d0%b2%d1%8b%d0%b2%d0%be%d0%b4%d0%be%d0%bc-%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%b8%d0%b9-%d0%b2-%d1%82%d0%b0%d0%b1%d0%bb%d0%b8\/"},"modified":"2017-07-06T22:55:14","modified_gmt":"2017-07-06T22:55:14","slug":"phpjquery-%d0%bf%d1%80%d0%be%d0%b1%d0%bb%d0%b5%d0%bc%d0%b0-%d1%81-%d0%b2%d1%8b%d0%b2%d0%be%d0%b4%d0%be%d0%bc-%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%b8%d0%b9-%d0%b2-%d1%82%d0%b0%d0%b1%d0%bb%d0%b8","status":"publish","type":"topic","link":"https:\/\/ru.wordpress.org\/support\/topic\/phpjquery-%d0%bf%d1%80%d0%be%d0%b1%d0%bb%d0%b5%d0%bc%d0%b0-%d1%81-%d0%b2%d1%8b%d0%b2%d0%be%d0%b4%d0%be%d0%bc-%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%b8%d0%b9-%d0%b2-%d1%82%d0%b0%d0%b1%d0%bb%d0%b8\/","title":{"rendered":"PHP+Jquery &#8212; \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443"},"content":{"rendered":"<p>\u0414\u043e\u0431\u0440\u044b\u0439 \u0432\u0435\u0447\u0435\u0440 \u0434\u0440\u0443\u0437\u044c\u044f.<br \/>\n\u0414\u0435\u043b\u0430\u044e \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e 2 \u0441\u0430\u0439\u0442\u0430 \u043d\u0430 \u0412\u043e\u0440\u0434\u043f\u0440\u0435\u0441 \u0438 DLE. \u0421\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0438 \u0440\u0435\u0448\u0438\u043b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0441\u044e\u0434\u0430, \u0442.\u043a. \u0437\u043d\u0430\u044e &#8212; \u0437\u0434\u0435\u0441\u044c \u043b\u044e\u0434\u0438 \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u044b\u0435&#8230;<br \/>\n\u0412 \u043e\u0431\u0449\u0435\u043c, \u0434\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u043f\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0443. \u0422.\u0435. \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0443 \u0410 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u0430 \u043d\u0430 \u0431\u0443\u043a\u0432\u0443 \u0410 \u0438 \u0442.\u0434.<\/p>\n<p>\u041a\u043e\u0434 PHP:<\/p>\n<pre><code>&lt;?php\n\ninclude (&#039;engine\/api\/api.class.php&#039;); \/\/ \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c api\n$table = &#039;dle_post&#039;;  \/\/ \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b\n$fields  = &#039;xfields&#039;; \/\/ \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u043e\u043b\u044f, * - \u0432\u0441\u0435 \u043f\u043e\u043b\u044f\n$where = &#039;approve=1&#039;; \/\/ \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438\n$multirow = 1; \/\/ \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c \u043b\u0438 \u043e\u0434\u0438\u043d \u0440\u044f\u0434 \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e\n$start = 0; \/\/ \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438\n$limit = 0; \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438, 0 - \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435\n$xfield = &#039;actor&#039;; \/\/\/\u0418\u041c\u042f \u0414\u041e\u041f \u041f\u041e\u041b\u042f \u0414\u041b\u042f \u0412\u042b\u0412\u041e\u0414\u0410\n$time = &#039;14000&#039;; \/\/\u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u043a\u0435\u0448\u0430\n$tr_new = 0; \/\/\u0412 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e\n\n$xfields = $dle_api-&gt;load_from_cache ($fields, $time, $xfields); \/\/\u0431\u0435\u0440\u0435\u043c \u043d\u0430\u0448 \u043a\u0435\u0448, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0435\u0447\u043d\u043e ))\nif( !$xfields ) { \/\/\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0437\u044f\u043b\u0438 \u043b\u0438 \u043c\u044b \u043a\u0435\u0448 \u0438 \u0435\u0441\u043b\u0438 \u043d\u0435 \u0432\u0437\u044f\u043b\u0438, \u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\n    $xfields = $dle_api-&gt;load_table ($table,$fields,$where,$multirow,$start,$limit); \/\/\u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0431\u0434\n    $dle_api-&gt;save_to_cache ( xfields, $xfields); \/\/\u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u043a\u0435\u0448\n    }\n\n$stack = array(); \/\/\u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\nforeach($xfields as $value){  \/\/ \u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\n    if($value[xfields]){ \/\/\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0441\u0442\u044c \u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435\n\n        $row = xfieldsdataload($value[xfields]); \/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u0434\u043e\u043f \u043f\u043e\u043b\u0435\n        if($row[$xfield]){ \/\/\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0441\u0442\u044c \u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\n\n            $rowdata = explode( &quot;,&quot;, $row[$xfield]); \/\/\u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\n            foreach($rowdata as $value){    \/\/\u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430\n                if($value){                    \/\/\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0441\u0442\u044c \u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\n                    $value = trim($value);    \/\/\u0443\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0440\u043e\u0431\u0435\u043b\u044b\n                    array_push($stack, $value); \/\/\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043a\u043e\u043d\u0435\u0446 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\n                    asort($stack);         \/\/\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430\n                    }\n                }\n            }\n        }\n    }\n$stack = array_count_values($stack); \/\/\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u044b \u0438 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u043e\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439\nforeach($stack as $key =&gt; $count){  \/\/\u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\n\nif($tr_new === 0){ \/\/\u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u043b\u044e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 TR\n    echo &#039;&lt;tr class=&quot;new&quot;&gt;&#039;;\n    }\n\n    echo &quot;&lt;td class=&#039;blok&#039;&gt;&quot;; \/\/\u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c td\n    echo &quot;&lt;a href=\/&quot; . $xfield . &quot;\/&quot;;  \/\/\u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443\n    echo $key; \/\/\u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430\n    echo &quot; target=&#039;_blank&#039; rel=&#039;noopener&#039;&gt;&quot;;\n    echo $key; \/\/\u0438\u043c\u044f \u0441\u0441\u044b\u043b\u043a\u0438\n    echo &quot;&lt;\/a&gt;&quot;; \/\/\u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443\n    echo &quot;&lt;span&gt;&quot;;  \/\/\u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u043f\u0430\u043d\n    echo &quot;(&quot; . $count . &quot;)&quot;;\/\/\u043a\u043e\u043b-\u0432\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043e\u0432\n    echo &quot;&lt;\/span&gt;&quot;; \/\/\u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u043f\u0430\u043d\n    echo &quot;&lt;\/td&gt;&quot;; \/\/\u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c td\n\n    $tr_new++; \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0434\u0438\u043d\u0438\u0446\u0443\n    if($tr_new === 1){ \/\/\u041f\u0440\u043e\u0448\u043b\u043e 1 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0437\u043d\u0430\u0447\u0438\u0442 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c TR \u0438 \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u0441\u0447\u0435\u0442\u0447\u0438\u043a\n    echo &#039;&lt;\/tr&gt;&#039;;\n    $tr_new = 0;\n    }\n}<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c JQuery:<\/p>\n<pre><code>$(function () {\n    var _alphabets = $(&#039;.alphabet &gt; a&#039;);\n    var _contentRows = $(&#039;#countries-table tbody tr&#039;);\n\n    _alphabets.click(function () {\n        var _letter = $(this), _text = $(this).text(), _count = 0;\n\n        _alphabets.removeClass(&quot;active&quot;);\n        _letter.addClass(&quot;active&quot;);\n\n        _contentRows.hide();\n        _contentRows.each(function (i) {\n            var _cellText = $(this).children(&#039;td&#039;).eq(0).text();\n            if (RegExp(&#039;^&#039; + _text).test(_cellText)) {\n                _count += 1;\n                $(this).fadeIn(400);\n            }\n        });\n    });\n});<\/code><\/pre>\n<p>\u0412\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0442\u0430\u043a:<\/p>\n<pre><code>&lt;div class=&quot;alphabet&quot;&gt;\n&lt;a class=&quot;first&quot; href=&quot;#&quot;&gt;\u0410&lt;\/a&gt;\n&lt;a href=&quot;#&quot;&gt;\u0411&lt;\/a&gt;\n&lt;a href=&quot;#&quot;&gt;\u0412&lt;\/a&gt;\n\u0438 \u0442.\u0434.\n&lt;a class=&quot;last&quot; href=&quot;#&quot;&gt;\u042f&lt;\/a&gt;&lt;\/div&gt;\n&lt;div id=&quot;conutries&quot;&gt;\n&lt;table id=&quot;countries-table&quot;&gt;\n&lt;tbody&gt;\n{include file=&quot;\/\u043a\u043e\u0434.php&quot;}\n&lt;\/tbody&gt;\n&lt;\/table&gt;\n&lt;\/div&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043e\u0434\u043d\u0430\u043a\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 &#8212; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 tr&#8230;<br \/>\n<img decoding=\"async\" src=\"https:\/\/i.stack.imgur.com\/U9C0a.png\" alt=\"\u0432\u044b\u0432\u043e\u0434 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e\" \/><\/p>\n<p>\u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 4 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 <code>if($tr_new === 4)<\/code> &#8212; \u043e\u043d\u0438 \u043d\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0443, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a:<br \/>\n<img decoding=\"async\" src=\"https:\/\/i.stack.imgur.com\/FzQ3S.png\" alt=\"\u0432\u044b\u0432\u043e\u0434 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443\" \/><\/p>\n<p>\u041a\u0430\u043a \u0438 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e?<br \/>\n\u0417\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u043e\u043c\u043e\u0449\u044c!<\/p>\n","protected":false},"template":"","class_list":["post-253204","topic","type-topic","status-publish","hentry","topic-tag-jquery","topic-tag-php"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/253204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/253204\/revisions"}],"wp:attachment":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=253204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}