{"id":70,"date":"2013-12-03T03:04:57","date_gmt":"2013-12-02T19:04:57","guid":{"rendered":"http:\/\/www.yptk.cn\/index.php\/2013\/12\/03\/%e5%8d%81%e5%a4%a9%e5%ad%a6%e4%bc%9aphp%e4%b9%8b%e7%ac%ac%e5%85%ab%e5%a4%a9\/"},"modified":"2013-12-03T03:04:57","modified_gmt":"2013-12-02T19:04:57","slug":"%e5%8d%81%e5%a4%a9%e5%ad%a6%e4%bc%9aphp%e4%b9%8b%e7%ac%ac%e5%85%ab%e5%a4%a9","status":"publish","type":"post","link":"http:\/\/yptk.cn\/index.php\/2013\/12\/03\/%e5%8d%81%e5%a4%a9%e5%ad%a6%e4%bc%9aphp%e4%b9%8b%e7%ac%ac%e5%85%ab%e5%a4%a9\/","title":{"rendered":"\u5341\u5929\u5b66\u4f1aphp\u4e4b\u7b2c\u516b\u5929"},"content":{"rendered":"<p><strong style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">&nbsp;\u5b66\u4e60\u76ee\u7684\uff1a\u505a\u4e00\u4e2a\u5206\u9875\u663e\u793a<br \/>\n<\/strong><span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; \u5173\u952e\u5c31\u662f\u7528\u5230\u4e86SQL\u8bed\u53e5\u4e2d\u7684limit\u6765\u9650\u5b9a\u663e\u793a\u7684\u8bb0\u5f55\u4ece\u51e0\u5230\u51e0\u3002\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u8bb0\u5f55\u5f53\u524d\u9875\u7684\u53d8\u91cf$page\uff0c\u8fd8\u9700\u8981\u603b\u5171\u7684\u8bb0\u5f55\u6570$num<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; \u5bf9\u4e8e$page\u5982\u679c\u6ca1\u6709\u6211\u4eec\u5c31\u8ba9\u5b83=0\uff0c\u5982\u679c\u6709&lt;0\u5c31\u8ba9\u5b83\u4e5f=0\uff0c\u5982\u679c\u8d85\u8fc7\u4e86\u603b\u7684\u9875\u6570\u5c31\u8ba9\u4ed6=\u603b\u7684\u9875\u6570\u3002<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; $execc=&#8221;select count(*) from tablename &#8220;;<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; $resultc=mysql_query($execc);<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; $rsc=mysql_fetch_array($resultc);<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; $num=$rsc[0];<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; \u8fd9\u6837\u53ef\u4ee5\u5f97\u5230\u8bb0\u5f55\u603b\u6570<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; ceil($num\/10))\u5982\u679c\u4e00\u987510\u8bb0\u5f55\u7684\u8bdd\uff0c\u8fd9\u4e2a\u5c31\u662f\u603b\u7684\u9875\u6570<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; \u6240\u4ee5\u53ef\u4ee5\u8fd9\u4e48\u5199<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; if(empty($_GET[&#8216;page&#8217;]))<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; {<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; $page=0;<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; }<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; else<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; {<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; $page=$_GET[&#8216;page&#8217;];<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; if($page&lt;0)$page=0;<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; if($page&gt;=ceil($num\/10))$page=ceil($num\/10)-1;\/\/\u56e0\u4e3apage\u662f\u4ece0\u5f00\u59cb\u7684\uff0c\u6240\u4ee5\u8981-1<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; }&nbsp;<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; \u8fd9\u6837$exec\u53ef\u4ee5\u8fd9\u4e48\u5199 $exec=&#8221;select * from tablename limit &#8220;.($page*10).&#8221;,10&#8243;;<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; \/\/\u4e00\u9875\u662f10\u8bb0\u5f55\u7684<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp;&nbsp;<\/span><strong style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\">\u6700\u540e\u6211\u4eec\u9700\u8981\u505a\u7684\u5c31\u662f\u51e0\u4e2a\u8fde\u63a5\uff1a<br \/>\n<\/strong><span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; &lt;a href=&#8221;xxx.php?page=0&#8243;&gt;FirstPage&lt;\/a&gt;&nbsp;<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; &lt;a href=&#8221;xxx.php?page=&lt;?=($page-1)?&gt;&#8221;&gt;PrevPage&lt;\/a&gt;&nbsp;<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; &lt;a href=&#8221;xxx.php?page=&lt;?=($page+1)?&gt;&#8221;&gt;NextPage&lt;\/a&gt;&nbsp;<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; &lt;a href=&#8221;xxx.php?page=&lt;?=ceil($num\/10)-1?&gt;&#8221;&gt;LastPage&lt;\/a&gt;<\/span><br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<br style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;\" \/><br \/>\n<span style=\"font-family:Simsun;font-size:14px;line-height:21.33333396911621px;white-space:normal;background-color:#FBFBFB;\">&nbsp; \u8fd9\u662f\u4e00\u4e2a\u5927\u81f4\u7684\u601d\u8def\uff0c\u5927\u5bb6\u53ef\u4ee5\u60f3\u60f3\u600e\u4e48\u6765\u4f18\u5316\uff1f\u4eca\u5929\u8bf4\u5230\u8fd9\u91cc\uff0c\u660e\u5929\u8bf4\u4e00\u4e0b\u4e00\u4e9b\u6ce8\u610f\u7684\u95ee\u9898\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;\u5b66\u4e60\u76ee\u7684\uff1a\u505a\u4e00\u4e2a\u5206\u9875\u663e\u793a &nbsp; \u5173\u952e\u5c31\u662f\u7528\u5230\u4e86SQL\u8bed\u53e5\u4e2d\u7684limit\u6765\u9650\u5b9a\u663e\u793a\u7684\u8bb0\u5f55\u4ece\u51e0\u5230\u51e0\u3002\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u8bb0\u5f55\u5f53\u524d\u9875\u7684\u53d8\u91cf$page\uff0c\u8fd8\u9700\u8981\u603b\u5171\u7684\u8bb0\u5f55\u6570$num &nbsp; \u5bf9\u4e8e$page\u5982\u679c\u6ca1\u6709\u6211\u4eec\u5c31\u8ba9\u5b83=0\uff0c\u5982\u679c\u6709&lt;0\u5c31\u8ba9\u5b83\u4e5f=0\uff0c\u5982\u679c\u8d85\u8fc7\u4e86\u603b\u7684\u9875\u6570\u5c31\u8ba9\u4ed6=\u603b\u7684\u9875\u6570\u3002 &nbsp; $execc=&#8221;select count(*) from tablen [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[15],"tags":[],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-15"],"_links":{"self":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/comments?post=70"}],"version-history":[{"count":0,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/posts\/70\/revisions"}],"wp:attachment":[{"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yptk.cn\/index.php\/wp-json\/wp\/v2\/tags?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}