{"id":2077,"date":"2024-11-10T11:15:25","date_gmt":"2024-11-10T03:15:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2077\/"},"modified":"2024-11-10T11:15:25","modified_gmt":"2024-11-10T03:15:25","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e5%bc%b9%e6%a1%86%e4%b8%ad%e8%8e%b7%e5%8f%96-foreach-%e5%be%aa%e7%8e%af%e4%b8%ad%e7%9a%84-id-%e5%80%bc%e5%b9%b6%e5%9c%a8%e9%93%be%e6%8e%a5%e4%b8%ad%e4%bc%a0%e9%80%92","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2077\/","title":{"rendered":"\u5982\u4f55\u5728\u5f39\u6846\u4e2d\u83b7\u53d6 FOREACH \u5faa\u73af\u4e2d\u7684 ID \u503c\u5e76\u5728\u94fe\u63a5\u4e2d\u4f20\u9012\u53c2\u6570\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173063755659056.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728\u5f39\u6846\u4e2d\u83b7\u53d6 FOREACH \u5faa\u73af\u4e2d\u7684 ID \u503c\u5e76\u5728\u94fe\u63a5\u4e2d\u4f20\u9012\u53c2\u6570\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5728\u5f39\u6846\u4e2d\u83b7\u53d6 FOREACH \u5faa\u73af\u4e2d\u7684 ID \u503c\u5e76\u5728\u94fe\u63a5\u4e2d\u4f20\u9012\u53c2\u6570\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4ece\u5f39\u6846\u4e2d\u83b7\u53d6 foreach \u5faa\u73af\u4e2d\u7684 id \u503c\uff0c\u5e76\u5728\u94fe\u63a5\u4e2d\u4f20\u9012\u53c2\u6570<\/strong><\/p>\n<p>\u5728\u5f39\u6846\u4e2d\u83b7\u53d6 foreach \u5faa\u73af\u4e2d\u7684 id \u503c\uff0c\u4ee5\u4e0b\u4e3a\u51e0\u79cd\u53ef\u884c\u7684\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528\u9690\u85cf\u8f93\u5165\u5b57\u6bb5<\/strong><\/p>\n<p>\u5728\u5f39\u6846\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u9690\u85cf\u8f93\u5165\u5b57\u6bb5\uff0c\u5e76\u4f7f\u7528 php \u8bbe\u7f6e\u8be5\u5b57\u6bb5\u7684\u503c\uff1a<\/p>\n<pre>&lt;input type=\"hidden\" name=\"user_id\" value=\"&lt;?php echo $val['c']['user_id']; ?&gt;\"&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>2. \u4f7f\u7528 javascript<\/strong><\/p>\n<p>\u5728\u5f39\u6846\u4e2d\u4f7f\u7528 javascript \u6765\u83b7\u53d6 id \u503c\u5e76\u5c06\u5176\u5b58\u50a8\u5728\u53d8\u91cf\u4e2d\uff1a<\/p>\n<pre>const userid = '&lt;?php echo $val['c']['user_id']; ?&gt;';<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>3. \u4f7f\u7528 jquery<\/strong><\/p>\n<p>\u4f7f\u7528 jquery \u6765\u83b7\u53d6 id \u503c\uff1a<\/p>\n<pre>$(document).ready(function() {\n  const userid = $('#user_id').val();\n});<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u5728\u94fe\u63a5\u4e2d\u4f20\u9012\u53c2\u6570<\/strong><\/p>\n<p>\u83b7\u53d6 id \u503c\u540e\uff0c\u5373\u53ef\u5728\u94fe\u63a5\u4e2d\u4f20\u9012\u8be5\u53c2\u6570\uff1a<\/p>\n<pre>&lt;a href=\"\/Index\/jxMoneyToBank?uid=&lt;?php echo $val['c']['user_id']; ?&gt;\" target=\"_blank\" class=\"b-color\"&gt;[\u53d6\u73b0]&lt;\/a&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5728\u5f39\u6846\u4e2d\u83b7\u53d6 FOREACH \u5faa\u73af\u4e2d\u7684 ID \u503c\u5e76\u5728\u94fe\u63a5\u4e2d\u4f20\u9012\u53c2\u6570\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4ece\u5f39\u6846\u4e2d\u83b7\u53d6 foreach \u5faa\u73af\u4e2d\u7684 id \u503c\uff0c\u5e76\u5728\u94fe\u63a5\u4e2d\u4f20\u9012\u53c2\u6570 \u5728\u5f39\u6846\u4e2d\u83b7\u53d6 foreach \u5faa\u73af\u4e2d\u7684 id \u503c\uff0c\u4ee5\u4e0b\u4e3a\u51e0\u79cd\u53ef\u884c\u7684\u89e3\u51b3\u65b9\u6848\uff1a 1. \u4f7f\u7528\u9690\u85cf\u8f93\u5165\u5b57\u6bb5 \u5728\u5f39\u6846\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u9690\u85cf\u8f93\u5165\u5b57\u6bb5\uff0c\u5e76\u4f7f\u7528 php \u8bbe\u7f6e\u8be5\u5b57\u6bb5\u7684\u503c\uff1a &lt;input type=&#8221;hidden&#8221; name=&#8221;user_id&#8221; value=&#8221;&lt;?php echo $val[&#8216;c&#8217;][&#8216;user_id&#8217;]; ?&gt;&#8221;&gt; \u767b\u5f55\u540e\u590d\u5236 2. \u4f7f\u7528 javascript \u5728\u5f39\u6846\u4e2d\u4f7f\u7528 javascript \u6765\u83b7\u53d6 id \u503c\u5e76\u5c06\u5176\u5b58\u50a8\u5728\u53d8\u91cf\u4e2d\uff1a const userid = &#8216;&lt;?php echo $val[&#8216;c&#8217;][&#8216;user_id&#8217;]; ?&gt;&#8217;; \u767b\u5f55\u540e\u590d\u5236 3. \u4f7f\u7528 jquery \u4f7f\u7528 jquery \u6765\u83b7\u53d6 id \u503c\uff1a $(document).ready(function() { const userid = $(&#8216;#user_id&#8217;).val(); }); \u767b\u5f55\u540e\u590d\u5236 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2077","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=2077"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2077\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}