<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>银子 's 博客</title>
	<atom:link href="http://www.zdyi.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.zdyi.com</link>
	<description>工作手记 - No silver bullet</description>
	<pubDate>Thu, 20 May 2010 03:29:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>随机数生成概率一解</title>
		<link>http://www.zdyi.com/rand-probability/544</link>
		<comments>http://www.zdyi.com/rand-probability/544#comments</comments>
		<pubDate>Thu, 20 May 2010 03:29:04 +0000</pubDate>
		<dc:creator>银子</dc:creator>
		
		<category><![CDATA[PHP&MySql]]></category>

		<category><![CDATA[概率]]></category>

		<category><![CDATA[生成]]></category>

		<category><![CDATA[随机数]]></category>

		<guid isPermaLink="false">http://www.zdyi.com/?p=544</guid>
		<description><![CDATA[比较常见的方面是把随机数生成为一个数组. 不过随机数比较多的情况下产生的数组也会特别大.
下面是另一种算法:

?View Code PHP1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$array = array&#40;1 =&#62; 30, 2 =&#62; 20, 3 =&#... ]]></description>
			<content:encoded><![CDATA[<p>比较常见的方面是把随机数生成为一个数组. 不过随机数比较多的情况下产生的数组也会特别大.</p>
<p>下面是另一种算法:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p544code2'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5442"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p544code2"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">,</span> <span style="color: #cc66cc;">6</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$rand</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mt_rand"><span style="color: #990000;">mt_rand</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$rand</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rand</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">101</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$max</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$v</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$max</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rand</span> <span style="color: #339933;">&lt;=</span> <span style="color: #000088;">$max</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$v</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$v</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zdyi.com/rand-probability/544/feed</wfw:commentRss>
		</item>
		<item>
		<title>PHP 求出3个坐标间的角度</title>
		<link>http://www.zdyi.com/php-angle/541</link>
		<comments>http://www.zdyi.com/php-angle/541#comments</comments>
		<pubDate>Tue, 04 May 2010 02:11:24 +0000</pubDate>
		<dc:creator>银子</dc:creator>
		
		<category><![CDATA[PHP&MySql]]></category>

		<category><![CDATA[坐标]]></category>

		<category><![CDATA[角度]]></category>

		<guid isPermaLink="false">http://www.zdyi.com/?p=541</guid>
		<description><![CDATA[原题地址: http://bbs.blueidea.com/viewthread.php?tid=2982704
先计算 AC 的弧度, 然后将弧度转换为角度.

?View Code PHP1
2
3
4
5
6
&#60;?php
$a = array&#40;'x' =&#62; 50, 'y' =&#62; 60&#41;;
$b = array&#40;'x' =&#62; 80, 'y' =&#62; 60&#4... ]]></description>
			<content:encoded><![CDATA[<p>原题地址: <a href="http://bbs.blueidea.com/viewthread.php?tid=2982704">http://bbs.blueidea.com/viewthread.php?tid=2982704</a></p>
<p>先计算 AC 的弧度, 然后将弧度转换为角度.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p541code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5414"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p541code4"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'y'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">80</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'y'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">80</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'y'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">70</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <a href="http://www.php.net/rad2deg"><span style="color: #990000;">rad2deg</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/atan2"><span style="color: #990000;">atan2</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'y'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'y'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'x'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'x'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zdyi.com/php-angle/541/feed</wfw:commentRss>
		</item>
		<item>
		<title>放出腾迅微博邀请码一枚</title>
		<link>http://www.zdyi.com/qq-invite/537</link>
		<comments>http://www.zdyi.com/qq-invite/537#comments</comments>
		<pubDate>Thu, 15 Apr 2010 06:37:21 +0000</pubDate>
		<dc:creator>银子</dc:creator>
		
		<category><![CDATA[Other]]></category>

		<category><![CDATA[腾迅]]></category>

		<category><![CDATA[邀请码]]></category>

		<guid isPermaLink="false">http://www.zdyi.com/?p=537</guid>
		<description><![CDATA[放出腾迅微博邀请码一枚 拿到的朋友请回复一下.
http://t.qq.com/invite/1385974e... ]]></description>
			<content:encoded><![CDATA[<p>放出腾迅微博邀请码一枚 拿到的朋友请回复一下.</p>
<p>http://t.qq.com/invite/1385974e</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zdyi.com/qq-invite/537/feed</wfw:commentRss>
		</item>
		<item>
		<title>[备忘]MySQL记录货币建议使用DECIMAL类型</title>
		<link>http://www.zdyi.com/mysql-decimal/534</link>
		<comments>http://www.zdyi.com/mysql-decimal/534#comments</comments>
		<pubDate>Mon, 12 Apr 2010 05:49:37 +0000</pubDate>
		<dc:creator>银子</dc:creator>
		
		<category><![CDATA[PHP&MySql]]></category>

		<category><![CDATA[DECIMAL]]></category>

		<category><![CDATA[MySql]]></category>

		<category><![CDATA[货币]]></category>

		<guid isPermaLink="false">http://www.zdyi.com/?p=534</guid>
		<description><![CDATA[DECIMAL和NUMERIC其实是视为相同的类型. 值是作为字符串存储, 而不是作为二进制浮点数. 这样就避免了FLOAT类型计算时出现的错误.... ]]></description>
			<content:encoded><![CDATA[<p>DECIMAL和NUMERIC其实是视为相同的类型. 值是作为字符串存储, 而不是作为二进制浮点数. 这样就避免了FLOAT类型计算时出现的错误.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zdyi.com/mysql-decimal/534/feed</wfw:commentRss>
		</item>
		<item>
		<title>2010年 为了地球关灯一小时</title>
		<link>http://www.zdyi.com/douse-the-glim-2010/525</link>
		<comments>http://www.zdyi.com/douse-the-glim-2010/525#comments</comments>
		<pubDate>Fri, 26 Mar 2010 06:02:46 +0000</pubDate>
		<dc:creator>银子</dc:creator>
		
		<category><![CDATA[Other]]></category>

		<category><![CDATA[关灯一小时]]></category>

		<category><![CDATA[地球]]></category>

		<guid isPermaLink="false">http://www.zdyi.com/?p=525</guid>
		<description><![CDATA[2010年3月27日，星期六，20：30 - 21：30 
行动起来，关灯一小时，应对气候变化


　　2010年3月27日20：30，“地球一小时”活动将在全球开展。加入我们的行列，熄灭灯光，向全世界发出“紧急行... ]]></description>
			<content:encoded><![CDATA[<p><strong>2010年3月27日，星期六，20：30 - 21：30 </strong><br />
行动起来，关灯一小时，应对气候变化</p>
<p><a href="http://www.zdyi.com/wp-content/uploads/2010/03/earth_hour_2010_poster.jpg" rel="lightbox"><img src="http://www.zdyi.com/wp-content/uploads/2010/03/earth_hour_2010_poster.jpg" alt="earth_hour_2010_poster" title="earth_hour_2010_poster" width="400" class="alignnone size-full wp-image-529" /></a></p>
<p><span id="more-525"></span></p>
<p>　　2010年3月27日20：30，“地球一小时”活动将在全球开展。加入我们的行列，熄灭灯光，向全世界发出“紧急行动，应对气候变化”的倡议。</p>
<p>　　地球一小时2010活动将号召每个人承担责任，为确保一个可持续的未来发挥自己的作用。</p>
<p>　　地球一小时2010年的目标：全球6000多个城市、超过10亿人参与活动，政府、企业、社区积极加入，让“地球一小时”成为世界上规模最大的环保行动。</p>
<p>　　在中国，我们正与合作伙伴共同努力，推动全国至少30个城市参与3月27日20：30的熄灯活动。</p>
<p>　　应对气候变化需要全球公众的强烈意愿与协作。中国政府已作出承诺，到2020年会在2005年碳排放量的基础上减排40%-45%。因此地球一小时2010也是传递中国公众对于中国减少温室气体排放，向低碳经济转变的支持。我们将在3月22日到3月26日（周一至周五）推出地球一小时低碳生活周，引领公众在日常生活中做出真正的低碳改变。</p>
<p>　　2007年，地球一小时发起于澳大利亚的悉尼，当年3月31日（星期六），超过220万家庭和企业在20：30关上了灯。2008年，全球更有约5000万到1亿人参与了地球一小时的活动。</p>
<p>　　在2009年，来自88个国家中4159个城市的数亿人参与行动。包括北京的鸟巢、水立方，上海的东方明珠、世界金融中心，吉萨的狮身人面像和金字塔，巴黎的埃菲尔铁塔在内的全球地标建筑都在当天关灯；</p>
<p>　　WWF号召：个人/志愿者 社区 学校 企业 政府加入我们，参与地球一小时2010活动。气候变化是一个不可改变的事实，它和我们每个人息息相关。地球一小时是带来希望和变革的契机。行动起来，世界将因此而改变。 3月27日20:30，2010“地球一小时”，期待您的参与！</p>
<p>上期回顾 <a href="http://www.zdyi.com/douse-the-glim/261">http://www.zdyi.com/douse-the-glim/261</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zdyi.com/douse-the-glim-2010/525/feed</wfw:commentRss>
		</item>
		<item>
		<title>[备忘]一个常用分页类</title>
		<link>http://www.zdyi.com/class-pagebar/520</link>
		<comments>http://www.zdyi.com/class-pagebar/520#comments</comments>
		<pubDate>Wed, 27 Jan 2010 05:43:52 +0000</pubDate>
		<dc:creator>银子</dc:creator>
		
		<category><![CDATA[PHP&MySql]]></category>

		<category><![CDATA[分页]]></category>

		<category><![CDATA[类]]></category>

		<guid isPermaLink="false">http://www.zdyi.com/?p=520</guid>
		<description><![CDATA[工作经常会用到的一个分页类..记录一下.

?View Code PHP1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
6... ]]></description>
			<content:encoded><![CDATA[<p>工作经常会用到的一个分页类..记录一下.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p520code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5206"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
</pre></td><td class="code" id="p520code6"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
Example: 
&nbsp;
$page = (isset($this-&gt;params['named']['page'])) ? $this-&gt;params['named']['page'] : 1;
// 导入分页类
App::import('Vendor', 'page_class');
// 获取公告总数
$total = $this-&gt;Bulletin-&gt;getBulletinTotal();
$perpage = ITEMPREPAGE;
$offset = $perpage * ($page - 1);
$pagebar = new Pagebar($total, $page, $offset, $perpage);
$pagenav = $pagebar-&gt;construct_page_nav($total, $page, SYSTEMURL . '/bulletins/index', null, null);
*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Pagebar
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$perpage</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
	<span style="color: #009933; font-style: italic;">/**
	* Ensures that the variables for a multi-page display are sane
	*
	* @param	integer	Total number of items to be displayed
	* @param	integer	(ref) Current page number
	* @param	integer	(ref) Desired number of results to show per-page
	*/</span>
	<span style="color: #000000; font-weight: bold;">function</span> Pagebar<span style="color: #009900;">&#40;</span><span style="color: #000088;">$numresults</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$page</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$limitlower</span><span style="color: #339933;">,</span> <span style="color: #000088;">$perpage</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">perpage</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$perpage</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$numpages</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ceil"><span style="color: #990000;">ceil</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numresults</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">perpage</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$numpages</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$numpages</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$numpages</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$numpages</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$limitlower</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">perpage</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$limitupper</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">perpage</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$limitupper</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$numresults</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$limitupper</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$numresults</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$limitlower</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$numresults</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$limitlower</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$numresults</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">perpage</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$limitlower</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$limitlower</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	* Returns the HTML for multi-page navigation
	*
	* @param	integer	Total number of items found
	* @param	integer	Page number being displayed
	* @param	string	Base address for links eg: q.php?t=99{&amp;page=4}
	* @param	string	Ending portion of address for links
	*
	* @return	string	Page navigation HTML
	*/</span>
	<span style="color: #000000; font-weight: bold;">function</span> construct_page_nav<span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pagenumber</span><span style="color: #339933;">,</span> <span style="color: #000088;">$address</span><span style="color: #339933;">,</span> <span style="color: #000088;">$address2</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$option</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$perpage</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">perpage</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$show</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$curpage</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$pagenav</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$firstlink</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$prevlink</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$lastlink</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$nextlink</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span> <span style="color: #339933;">&lt;=</span> <span style="color: #000088;">$perpage</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pagenav'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pagenav'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/number_format"><span style="color: #990000;">number_format</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$totalpages</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ceil"><span style="color: #990000;">ceil</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$perpage</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'prev'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'next'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'first'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'last'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pagenumber</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$prevpage</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pagenumber</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$prevnumbers</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_start_end_total_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$prevpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$perpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'prev'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pagenumber</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$totalpages</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$nextpage</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pagenumber</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$nextnumbers</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_start_end_total_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nextpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$perpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'next'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// create array of possible relative links that we might have (eg. +10, +20, +50, etc.)</span>
		<span style="color: #000088;">$pagenavsarr</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">500</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$pagenavpages</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curpage</span><span style="color: #339933;">++</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$totalpages</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/abs"><span style="color: #990000;">abs</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curpage</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$pagenumber</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$pagenavpages</span> AND <span style="color: #000088;">$pagenavpages</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curpage</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$firstnumbers</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_start_end_total_array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$perpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'first'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curpage</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$totalpages</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$lastnumbers</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_start_end_total_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$totalpages</span><span style="color: #339933;">,</span> <span style="color: #000088;">$perpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'last'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #666666; font-style: italic;">// generate relative links (eg. +10,etc).</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/abs"><span style="color: #990000;">abs</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curpage</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$pagenumber</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pagenavsarr</span><span style="color: #009900;">&#41;</span> AND <span style="color: #000088;">$curpage</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">1</span> AND <span style="color: #000088;">$curpage</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$totalpages</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$pagenumbers</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_start_end_total_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$perpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$relpage</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$curpage</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$pagenumber</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$relpage</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$relpage</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'+'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$relpage</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
&nbsp;
					<span style="color: #000088;">$pagenav</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;a onclick=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$option[onclick]</span><span style="color: #000099; font-weight: bold;">\&quot;</span> class=<span style="color: #000099; font-weight: bold;">\&quot;</span>smallfont<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$address</span>&quot;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/page:<span style="color: #006699; font-weight: bold;">$curpage</span>&quot;</span><span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$address2</span> ? <span style="color: #0000ff;">'?'</span><span style="color: #339933;">.</span><span style="color: #000088;">$address2</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span>显示结果从 <span style="color: #006699; font-weight: bold;">$pagenumbers[first]</span> 到 <span style="color: #006699; font-weight: bold;">$pagenumbers[last]</span> 共计 <span style="color: #006699; font-weight: bold;">$total</span> 条<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;!--<span style="color: #006699; font-weight: bold;">$relpage</span>--&gt; <span style="color: #006699; font-weight: bold;">$curpage</span> &lt;/a&gt;&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curpage</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$pagenumber</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$numbers</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_start_end_total_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$perpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$pagenav</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;	&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>smallfont<span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span>显示结果从 <span style="color: #006699; font-weight: bold;">$numbers[first]</span> 到 <span style="color: #006699; font-weight: bold;">$numbers[last]</span> 共计 <span style="color: #006699; font-weight: bold;">$total</span> 条<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;strong&gt; <span style="color: #006699; font-weight: bold;">$curpage</span> &lt;/strong&gt;&lt;/span&gt;&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$pagenumbers</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_start_end_total_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$perpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$pagenav</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;a onclick=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$option[onclick]</span><span style="color: #000099; font-weight: bold;">\&quot;</span> class=<span style="color: #000099; font-weight: bold;">\&quot;</span>smallfont<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$address</span>&quot;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/page:<span style="color: #006699; font-weight: bold;">$curpage</span>&quot;</span><span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$address2</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'?'</span><span style="color: #339933;">.</span><span style="color: #000088;">$address2</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span>显示结果从 <span style="color: #006699; font-weight: bold;">$pagenumbers[first]</span> 到 <span style="color: #006699; font-weight: bold;">$pagenumbers[last]</span> 共计 <span style="color: #006699; font-weight: bold;">$total</span> 条<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt; <span style="color: #006699; font-weight: bold;">$curpage</span> &lt;/a&gt;&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$pagenav</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;
                &lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>disabled<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;
                &quot;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'prev'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;a onclick=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$option[onclick]</span><span style="color: #000099; font-weight: bold;">\&quot;</span> class=<span style="color: #000099; font-weight: bold;">\&quot;</span>smallfont<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$address</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/page:<span style="color: #006699; font-weight: bold;">$prevpage</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$address2</span> ? <span style="color: #0000ff;">'?'</span><span style="color: #339933;">.</span><span style="color: #000088;">$address2</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span>上一页 - 结果从 <span style="color: #006699; font-weight: bold;">$prevnumbers[first]</span> 到 <span style="color: #006699; font-weight: bold;">$prevnumbers[last]</span> 共计 <span style="color: #006699; font-weight: bold;">$total</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;上一页&lt;/a&gt;&lt;/span&gt;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;上一页&lt;/span&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;
&nbsp;
                <span style="color: #006699; font-weight: bold;">$pagenav</span>
&nbsp;
                &quot;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$show</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'next'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;span&gt;&lt;a onclick=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$option[onclick]</span><span style="color: #000099; font-weight: bold;">\&quot;</span> class=<span style="color: #000099; font-weight: bold;">\&quot;</span>smallfont<span style="color: #000099; font-weight: bold;">\&quot;</span> href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$address</span>/page:<span style="color: #006699; font-weight: bold;">$nextpage</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$address2</span> ? <span style="color: #0000ff;">'?'</span><span style="color: #339933;">.</span><span style="color: #000088;">$address2</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span>下一页 - 结果从 <span style="color: #006699; font-weight: bold;">$nextnumbers[first]</span> 到 <span style="color: #006699; font-weight: bold;">$nextnumbers[last]</span> 共计 <span style="color: #006699; font-weight: bold;">$total</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;下一页&lt;/a&gt;&lt;/span&gt;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;span&gt;下一页&lt;/span&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;
&nbsp;
				&lt;span&gt;第 <span style="color: #006699; font-weight: bold;">$pagenumber</span> / <span style="color: #006699; font-weight: bold;">$totalpages</span> 页,共 &lt;strong&gt;<span style="color: #006699; font-weight: bold;">$total</span>&lt;/strong&gt;条记录&lt;/span&gt;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$pagenav</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009933; font-style: italic;">/**
	* Returns an array so you can print 'Showing results $arr[first] to $arr[last] of $totalresults'
	*
	* @param	integer	Current page number
	* @param	integer	Results to show per-page
	* @param	integer	Total results found
	*
	* @return	array	In the format of - array('first' =&gt; x, 'last' =&gt; y)
	*/</span>
	<span style="color: #000000; font-weight: bold;">function</span> fetch_start_end_total_array<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pagenumber</span><span style="color: #339933;">,</span> <span style="color: #000088;">$perpage</span><span style="color: #339933;">,</span> <span style="color: #000088;">$total</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$first</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$perpage</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pagenumber</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$last</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$first</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$perpage</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$last</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$total</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$last</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$total</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$first</span><span style="color: #339933;">++;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'first'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/number_format"><span style="color: #990000;">number_format</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$first</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'last'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/number_format"><span style="color: #990000;">number_format</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$last</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zdyi.com/class-pagebar/520/feed</wfw:commentRss>
		</item>
		<item>
		<title>近期工作摘记</title>
		<link>http://www.zdyi.com/work-take-notes/516</link>
		<comments>http://www.zdyi.com/work-take-notes/516#comments</comments>
		<pubDate>Tue, 19 Jan 2010 09:47:12 +0000</pubDate>
		<dc:creator>银子</dc:creator>
		
		<category><![CDATA[About]]></category>

		<category><![CDATA[摘记]]></category>

		<category><![CDATA[近期工作]]></category>

		<guid isPermaLink="false">http://www.zdyi.com/?p=516</guid>
		<description><![CDATA[因为最近比较忙,很久没更新博客了,草草几行,记录近期工作
公司
1. 年终晚会抽奖程序 AS3编写 基本完成
2. 内部系统(保密) PHP编写
个人
1. 歪藕 目前还是构思阶段,有部分数据供搜索引擎抓取.
2. ... ]]></description>
			<content:encoded><![CDATA[<p>因为最近比较忙,很久没更新博客了,草草几行,记录近期工作</p>
<p>公司</p>
<p>1. 年终晚会抽奖程序 AS3编写 基本完成<br />
2. 内部系统(保密) PHP编写</p>
<p>个人</p>
<p>1. <a href="http://www.ywowy.com" target="_blank">歪藕</a> 目前还是构思阶段,有部分数据供搜索引擎抓取.<br />
2. 某地区人才网站, 代码编写中,计划用PHP开发, 前期准备工作基本完成, 预期用时为三个月.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zdyi.com/work-take-notes/516/feed</wfw:commentRss>
		</item>
		<item>
		<title>[备忘]Mysql中explain的使用详解</title>
		<link>http://www.zdyi.com/mysql-explain/510</link>
		<comments>http://www.zdyi.com/mysql-explain/510#comments</comments>
		<pubDate>Mon, 07 Dec 2009 03:26:01 +0000</pubDate>
		<dc:creator>银子</dc:creator>
		
		<category><![CDATA[PHP&MySql]]></category>

		<category><![CDATA[explain]]></category>

		<category><![CDATA[MySql]]></category>

		<category><![CDATA[详解]]></category>

		<guid isPermaLink="false">http://www.zdyi.com/?p=510</guid>
		<description><![CDATA[explain显示了mysql如何使用索引来处理select语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句.
使用方法:在select语句前加上explain.  如 EXPLAIN SELECT * FROM `users`
Explain 列的解释：
table... ]]></description>
			<content:encoded><![CDATA[<p>explain显示了mysql如何使用索引来处理select语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句.<br />
使用方法:在select语句前加上explain.  如 EXPLAIN SELECT * FROM `users`</p>
<p><strong>Explain 列的解释：</strong><br />
table 显示这一行的数据是关于哪张表的<br />
type  这是重要的列，显示连接使用了何种类型。从最好到最差的连接类型为const、eq_reg、ref、range、indexhe和ALL<br />
possible_keys 显示可能应用在这张表中的索引。如果为空，没有可能的索引。可以为相关的域从WHERE语句中选择一个合适的语句<br />
key 实际使用的索引。如果为NULL，则没有使用索引。很少的情况下，MYSQL会选择优化不足的索引。这种情况下，可以在SELECT语句中使用USE INDEX（indexname）来强制使用一个索引或者用IGNORE INDEX（indexname）来强制MYSQL忽略索引<br />
key_len 使用的索引的长度。在不损失精确性的情况下，长度越短越好<br />
ref 显示索引的哪一列被使用了，如果可能的话，是一个常数<br />
rows MYSQL认为必须检查的用来返回请求数据的行数<br />
Extra 关于MYSQL如何解析查询的额外信息。这里可以看到的坏的例子是Using temporary和Using filesort，意思MYSQL根本不能使用索引，结果是检索会很慢</p>
<p><span id="more-510"></span></p>
<p><strong>Extra 列返回的描述的意义</strong><br />
Distinct 一旦MYSQL找到了与行相联合匹配的行，就不再搜索了<br />
Not exists MYSQL优化了LEFT JOIN，一旦它找到了匹配LEFT JOIN标准的行，就不再搜索了<br />
Range checked for each<br />
Record（index map:#）没有找到理想的索引，因此对于从前面表中来的每一个行组合，MYSQL检查使用哪个索引，并用它来从表中返回行。这是使用索引的最慢的连接之一<br />
Using filesort 看到这个的时候，查询就需要优化了。MYSQL需要进行额外的步骤来发现如何对返回的行排序。它根据连接类型以及存储排序键值和匹配条件的全部行的行指针来排序全部行<br />
Using index 列数据是从仅仅使用了索引中的信息而没有读取实际的行动的表返回的，这发生在对表的全部的请求列都是同一个索引的部分的时候<br />
Using temporary 看到这个的时候，查询需要优化了。这里，MYSQL需要创建一个临时表来存储结果，这通常发生在对不同的列集进行ORDER BY上，而不是GROUP BY上<br />
Where used 使用了WHERE从句来限制哪些行将与下一张表匹配或者是返回给用户。如果不想返回表中的全部行，并且连接类型ALL或index，这就会发生，或者是查询有问题</p>
<p><strong>不同连接类型的解释（按照效率高低的顺序排序）</strong><br />
system 表只有一行：system表。这是const连接类型的特殊情况<br />
const 表中的一个记录的最大值能够匹配这个查询（索引可以是主键或惟一索引）。因为只有一行，这个值实际就是常数，因为MYSQL先读这个值然后把它当做常数来对待<br />
eq_ref 在连接中，MYSQL在查询时，从前面的表中，对每一个记录的联合都从表中读取一个记录，它在查询使用了索引为主键或惟一键的全部时使用<br />
ref 这个连接类型只有在查询使用了不是惟一或主键的键或者是这些类型的部分（比如，利用最左边前缀）时发生。对于之前的表的每一个行联合，全部记录都将从表中读出。这个类型严重依赖于根据索引匹配的记录多少—越少越好<br />
range 这个连接类型使用索引返回一个范围中的行，比如使用>或<查找东西时发生的情况<br />
index 这个连接类型对前面的表中的每一个记录联合进行完全扫描（比ALL更好，因为索引一般小于表数据）<br />
ALL 这个连接类型对于前面的每一个记录联合进行完全扫描，这一般比较糟糕，应该尽量避免 </p>
]]></content:encoded>
			<wfw:commentRss>http://www.zdyi.com/mysql-explain/510/feed</wfw:commentRss>
		</item>
		<item>
		<title>[备忘]PHP简单调试</title>
		<link>http://www.zdyi.com/php-debug/508</link>
		<comments>http://www.zdyi.com/php-debug/508#comments</comments>
		<pubDate>Wed, 25 Nov 2009 03:27:36 +0000</pubDate>
		<dc:creator>银子</dc:creator>
		
		<category><![CDATA[PHP&MySql]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[简单调试]]></category>

		<guid isPermaLink="false">http://www.zdyi.com/?p=508</guid>
		<description><![CDATA[还是很方便的调试方式..记录一下备忘

?View Code PHP1
2
ini_set&#40;&#34;error_log&#34;, &#34;E:\php_error.log&#34;&#41;;  
error_log&#40;$output,0&#41;;
... ]]></description>
			<content:encoded><![CDATA[<p>还是很方便的调试方式..记录一下备忘</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p508code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5088"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p508code8"><pre class="php" style="font-family:monospace;"><a href="http://www.php.net/ini_set"><span style="color: #990000;">ini_set</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;error_log&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;E:\php_error.log&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
<a href="http://www.php.net/error_log"><span style="color: #990000;">error_log</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zdyi.com/php-debug/508/feed</wfw:commentRss>
		</item>
		<item>
		<title>php生成渐变图片</title>
		<link>http://www.zdyi.com/php-gd-image/503</link>
		<comments>http://www.zdyi.com/php-gd-image/503#comments</comments>
		<pubDate>Fri, 13 Nov 2009 02:04:27 +0000</pubDate>
		<dc:creator>银子</dc:creator>
		
		<category><![CDATA[PHP&MySql]]></category>

		<category><![CDATA[gd]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[图片]]></category>

		<category><![CDATA[渐变]]></category>

		<guid isPermaLink="false">http://www.zdyi.com/?p=503</guid>
		<description><![CDATA[问题链接：http://bbs.blueidea.com/thread-2957105-1-1.html
我是使用GD的 imagefilledrectangle 函数来实现的. 不知是否有更好的解法

?View Code PHP1
2
3
4
5
6
7
8
9
10
11
12
&#60;?php
$im = imagecreate&#40;255, 255&#41;;
$bg = imagec... ]]></description>
			<content:encoded><![CDATA[<p>问题链接：<a href="http://bbs.blueidea.com/thread-2957105-1-1.html" target="_blank">http://bbs.blueidea.com/thread-2957105-1-1.html</a></p>
<p>我是使用GD的 imagefilledrectangle 函数来实现的. 不知是否有更好的解法</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p503code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p50310"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p503code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$im</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreate"><span style="color: #990000;">imagecreate</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bg</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecolorallocate"><span style="color: #990000;">imagecolorallocate</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">255</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&gt;=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$color</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecolorallocate"><span style="color: #990000;">imagecolorallocate</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/imagefilledrectangle"><span style="color: #990000;">imagefilledrectangle</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$color</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: image/png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/imagepng"><span style="color: #990000;">imagepng</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/imagedestroy"><span style="color: #990000;">imagedestroy</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zdyi.com/php-gd-image/503/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
