<?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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Learning Is Fun</title>
	<atom:link href="http://www.tanzilo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tanzilo.com</link>
	<description>Talks on Web Technology and Better Product Development</description>
	<lastBuildDate>Sat, 29 Jan 2011 22:03:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>PHP: Convert number &amp; currency to text in asian i.e. Bangladeshi, Indian format</title>
		<link>http://www.tanzilo.com/2011/01/28/php-convert-number-currency-to-text-in-asian-i-e-bangladeshi-indian-format/</link>
		<comments>http://www.tanzilo.com/2011/01/28/php-convert-number-currency-to-text-in-asian-i-e-bangladeshi-indian-format/#comments</comments>
		<pubDate>Fri, 28 Jan 2011 15:45:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=112</guid>
		<description><![CDATA[Hello Guys, I am from Bangladesh and our currency system is somewhat different. We use lac/lakh, crore etc. So, today I had to convert number to word in a project. When I was searching the web, I did not found anything that meets my requirement 100%. So I wrote one. Although my code does not [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Guys,</p>
<p>I am from Bangladesh and our currency system is somewhat different. We use lac/lakh, crore etc. So, today I had to convert number to word in a project. When I was searching the web, I did not found anything that meets my requirement 100%. So I wrote one. Although my code does not support more than 999 crore taka / rupee, I think this will suffice most of the projects requirements.</p>
<p>To be frank I used several pieces of beautiful code from internet.</p>
<p>Well. Enough talks. Let me show the code.</p>
<p>CODE:</p>
<p>================================================</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>

	<span class="php-function">error_reporting</span><span class="php-brackets">(</span><span class="php-constant">E_ALL</span><span class="php-brackets">)</span>;
	<span class="php-comment">//error_reporting(0);
</span>

	<span class="php-keyword">class</span> Currency
	<span class="php-brackets">{</span>

		<span class="php-function">function</span> __construct<span class="php-brackets">(</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-comment">//do nothing for now
</span>
		<span class="php-brackets">}</span>

		<span class="php-comment">// http://www.phpbuilder.com/board/showthread.php?t=10350901
</span>
		<span class="php-function">function</span> get_bd_money_format<span class="php-brackets">(</span><span class="php-var">$amount</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-var">$output_string</span> <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-var">$tokens</span> <span class="php-operator">=</span> <span class="php-function">explode</span><span class="php-brackets">(</span><span class="php-string">'.'</span>, <span class="php-var">$amount</span><span class="php-brackets">)</span>;
			<span class="php-var">$number</span> <span class="php-operator">=</span> <span class="php-var">$tokens</span><span class="php-brackets">[</span><span class="php-number">0</span><span class="php-brackets">]</span>;
			<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-function">count</span><span class="php-brackets">(</span><span class="php-var">$tokens</span><span class="php-brackets">)</span> <span class="php-operator">&gt;</span> <span class="php-number">1</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-brackets">(</span>double<span class="php-brackets">)</span><span class="php-brackets">(</span><span class="php-string">'0.'</span> <span class="php-operator">.</span> <span class="php-var">$tokens</span><span class="php-brackets">[</span><span class="php-number">1</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
				<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-var">$fraction</span> <span class="php-operator">*</span> <span class="php-number">1</span><span class="php-number">0</span><span class="php-number">0</span>;
				<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-function">round</span><span class="php-brackets">(</span><span class="php-var">$fraction</span>, <span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-string">'.'</span> <span class="php-operator">.</span> <span class="php-var">$fraction</span>;
			<span class="php-brackets">}</span>

			<span class="php-var">$number</span> <span class="php-operator">=</span> <span class="php-var">$number</span> <span class="php-operator">.</span> <span class="php-string">''</span>;
			<span class="php-var">$spl</span><span class="php-operator">=</span><span class="php-function">str_split</span><span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-brackets">)</span>;
			<span class="php-var">$lpcount</span><span class="php-operator">=</span><span class="php-function">count</span><span class="php-brackets">(</span><span class="php-var">$spl</span><span class="php-brackets">)</span>;
			<span class="php-var">$rem</span><span class="php-operator">=</span><span class="php-var">$lpcount</span><span class="php-operator">-</span><span class="php-number">3</span>;
			<span class="php-comment">//echo &quot;rem&quot;.$rem.&quot;&lt;br/&gt;&quot;;
</span>
			<span class="php-comment">//even one
</span>
			<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-var">$lpcount</span><span class="php-operator">%</span><span class="php-number">2</span><span class="php-operator">=</span><span class="php-operator">=</span><span class="php-number">0</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">for</span><span class="php-brackets">(</span><span class="php-var">$i</span><span class="php-operator">=</span><span class="php-number">0</span>;<span class="php-var">$i</span><span class="php-operator">&lt;</span><span class="php-operator">=</span><span class="php-var">$lpcount</span><span class="php-operator">-</span><span class="php-number">1</span>;<span class="php-var">$i</span><span class="php-operator">+</span><span class="php-operator">+</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>

					<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-var">$i</span><span class="php-operator">%</span><span class="php-number">2</span><span class="php-operator">!</span><span class="php-operator">=</span><span class="php-number">0</span> <span class="php-operator">&amp;</span><span class="php-operator">&amp;</span> <span class="php-var">$i</span><span class="php-operator">!</span><span class="php-operator">=</span><span class="php-number">0</span> <span class="php-operator">&amp;</span><span class="php-operator">&amp;</span> <span class="php-var">$i</span><span class="php-operator">!</span><span class="php-operator">=</span><span class="php-var">$lpcount</span><span class="php-operator">-</span><span class="php-number">1</span><span class="php-brackets">)</span>
					<span class="php-brackets">{</span>
						<span class="php-var">$output_string</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">&quot;,&quot;</span>;
					<span class="php-brackets">}</span>
					<span class="php-var">$output_string</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-var">$spl</span><span class="php-brackets">[</span><span class="php-var">$i</span><span class="php-brackets">]</span>;
				<span class="php-brackets">}</span>
			<span class="php-brackets">}</span>
			<span class="php-comment">//odd one
</span>
			<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-var">$lpcount</span><span class="php-operator">%</span><span class="php-number">2</span><span class="php-operator">!</span><span class="php-operator">=</span><span class="php-number">0</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">for</span><span class="php-brackets">(</span><span class="php-var">$i</span><span class="php-operator">=</span><span class="php-number">0</span>;<span class="php-var">$i</span><span class="php-operator">&lt;</span><span class="php-operator">=</span><span class="php-var">$lpcount</span><span class="php-operator">-</span><span class="php-number">1</span>;<span class="php-var">$i</span><span class="php-operator">+</span><span class="php-operator">+</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-var">$i</span><span class="php-operator">%</span><span class="php-number">2</span><span class="php-operator">=</span><span class="php-operator">=</span><span class="php-number">0</span> <span class="php-operator">&amp;</span><span class="php-operator">&amp;</span> <span class="php-var">$i</span><span class="php-operator">!</span><span class="php-operator">=</span><span class="php-number">0</span> <span class="php-operator">&amp;</span><span class="php-operator">&amp;</span> <span class="php-var">$i</span><span class="php-operator">!</span><span class="php-operator">=</span><span class="php-var">$lpcount</span><span class="php-operator">-</span><span class="php-number">1</span><span class="php-brackets">)</span>
					<span class="php-brackets">{</span>
						<span class="php-var">$output_string</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">&quot;,&quot;</span>;
					<span class="php-brackets">}</span>
					<span class="php-var">$output_string</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-var">$spl</span><span class="php-brackets">[</span><span class="php-var">$i</span><span class="php-brackets">]</span>;
				<span class="php-brackets">}</span>
			<span class="php-brackets">}</span>
			<span class="php-keyword">return</span> <span class="php-var">$output_string</span> <span class="php-operator">.</span> <span class="php-var">$fraction</span>;
		<span class="php-brackets">}</span>

		<span class="php-comment">// http://efreedom.com/Question/1-3181945/Convert-Money-Text-PHP
</span>
		<span class="php-function">function</span> translate_to_words<span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
		<span class="php-comment">/*****
			 * A recursive function to turn digits into words
			 * Numbers must be integers from -999,999,999,999 to 999,999,999,999 inclussive.
			 *
			 *  (C) 2010 Peter Ajtai
			 *    This program is free software: you can redistribute it and/or modify
			 *    it under the terms of the GNU General Public License as published by
			 *    the Free Software Foundation, either version 3 of the License, or
			 *    (at your option) any later version.
			 *
			 *    This program is distributed in the hope that it will be useful,
			 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
			 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
			 *    GNU General Public License for more details.
			 *
			 *    See the GNU General Public License: &lt;http://www.gnu.org/licenses/&gt;.
			 *
			 */</span>
			<span class="php-comment">// zero is a special case, it cause problems even with typecasting if we don't deal with it here
</span>
			<span class="php-var">$max_size</span> <span class="php-operator">=</span> <span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">1</span><span class="php-number">8</span><span class="php-brackets">)</span>;
			<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-var">$number</span><span class="php-brackets">)</span> <span class="php-keyword">return</span> <span class="php-string">&quot;zero&quot;</span>;
			<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-function">is_int</span><span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-brackets">)</span> <span class="php-operator">&amp;</span><span class="php-operator">&amp;</span> <span class="php-var">$number</span> <span class="php-operator">&lt;</span> <span class="php-function">abs</span><span class="php-brackets">(</span><span class="php-var">$max_size</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-var">$prefix</span> <span class="php-operator">=</span> <span class="php-string">''</span>;
				<span class="php-var">$suffix</span> <span class="php-operator">=</span> <span class="php-string">''</span>;
				<span class="php-keyword">switch</span> <span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-comment">// set up some rules for converting digits to words
</span>
					<span class="php-keyword">case</span> <span class="php-var">$number</span> <span class="php-operator">&lt;</span> <span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$prefix</span> <span class="php-operator">=</span> <span class="php-string">&quot;negative&quot;</span>;
						<span class="php-var">$suffix</span> <span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-operator">-</span><span class="php-number">1</span><span class="php-operator">*</span><span class="php-var">$number</span><span class="php-brackets">)</span>;
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-var">$prefix</span> <span class="php-operator">.</span> <span class="php-string">&quot; &quot;</span> <span class="php-operator">.</span> <span class="php-var">$suffix</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">1</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;one&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">2</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;two&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">3</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;three&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">4</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;four&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">5</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;five&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">6</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;six&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">7</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;seven&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">8</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;eight&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">9</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;nine&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">1</span><span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;ten&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">1</span><span class="php-number">1</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;eleven&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">1</span><span class="php-number">2</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;twelve&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">1</span><span class="php-number">3</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;thirteen&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-comment">// fourteen handled later
</span>
					<span class="php-keyword">case</span> <span class="php-number">1</span><span class="php-number">5</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;fifteen&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-var">$number</span> <span class="php-operator">&lt;</span> <span class="php-number">2</span><span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-operator">%</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
						<span class="php-comment">// eighteen only has one &quot;t&quot;
</span>
						<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-var">$number</span> <span class="php-operator">=</span><span class="php-operator">=</span> <span class="php-number">1</span><span class="php-number">8</span><span class="php-brackets">)</span>
						<span class="php-brackets">{</span>
						<span class="php-var">$suffix</span> <span class="php-operator">=</span> <span class="php-string">&quot;een&quot;</span>;
						<span class="php-brackets">}</span> <span class="php-keyword">else</span>
						<span class="php-brackets">{</span>
						<span class="php-var">$suffix</span> <span class="php-operator">=</span> <span class="php-string">&quot;teen&quot;</span>;
						<span class="php-brackets">}</span>
						<span class="php-var">$string</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-var">$suffix</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">2</span><span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;twenty&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">3</span><span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;thirty&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">4</span><span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;forty&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">5</span><span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;fifty&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">6</span><span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;sixty&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">7</span><span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;seventy&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">8</span><span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;eighty&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-number">9</span><span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-string">&quot;ninety&quot;</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-var">$number</span> <span class="php-operator">&lt;</span> <span class="php-number">1</span><span class="php-number">0</span><span class="php-number">0</span><span class="php-operator">:</span>
						<span class="php-var">$prefix</span> <span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-operator">-</span><span class="php-var">$number</span><span class="php-operator">%</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
						<span class="php-var">$suffix</span> <span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-operator">%</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
						<span class="php-comment">//$string = $prefix . &quot;-&quot; . $suffix;
</span>
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-var">$prefix</span> <span class="php-operator">.</span> <span class="php-string">&quot; &quot;</span> <span class="php-operator">.</span> <span class="php-var">$suffix</span>;
						<span class="php-keyword">break</span>;
					<span class="php-comment">// handles all number 100 to 999
</span>
					<span class="php-keyword">case</span> <span class="php-var">$number</span> <span class="php-operator">&lt;</span> <span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">3</span><span class="php-brackets">)</span><span class="php-operator">:</span>
						<span class="php-comment">// floor return a float not an integer
</span>
						<span class="php-var">$prefix</span> <span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-function">intval</span><span class="php-brackets">(</span><span class="php-function">floor</span><span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-operator">/</span><span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">2</span><span class="php-brackets">)</span><span class="php-brackets">)</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">&quot; hundred&quot;</span>;
						<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-operator">%</span><span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">2</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-var">$suffix</span> <span class="php-operator">=</span> <span class="php-string">&quot; and &quot;</span> <span class="php-operator">.</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-operator">%</span><span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">2</span><span class="php-brackets">)</span><span class="php-brackets">)</span>;
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-var">$prefix</span> <span class="php-operator">.</span> <span class="php-var">$suffix</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-var">$number</span> <span class="php-operator">&lt;</span> <span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">6</span><span class="php-brackets">)</span><span class="php-operator">:</span>
						<span class="php-comment">// floor return a float not an integer
</span>
						<span class="php-var">$prefix</span> <span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-function">intval</span><span class="php-brackets">(</span><span class="php-function">floor</span><span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-operator">/</span><span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">3</span><span class="php-brackets">)</span><span class="php-brackets">)</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">&quot; thousand&quot;</span>;
						<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-operator">%</span><span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">3</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-var">$suffix</span> <span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-var">$number</span><span class="php-operator">%</span><span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">3</span><span class="php-brackets">)</span><span class="php-brackets">)</span>;
						<span class="php-var">$string</span> <span class="php-operator">=</span> <span class="php-var">$prefix</span> <span class="php-operator">.</span> <span class="php-string">&quot; &quot;</span> <span class="php-operator">.</span> <span class="php-var">$suffix</span>;
						<span class="php-keyword">break</span>;
				<span class="php-brackets">}</span>
			<span class="php-brackets">}</span> <span class="php-keyword">else</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">echo</span> <span class="php-string">&quot;ERROR with - $number&lt;br/&gt; Number must be an integer between -&quot;</span> <span class="php-operator">.</span> <span class="php-function">number_format</span><span class="php-brackets">(</span><span class="php-var">$max_size</span>, <span class="php-number">0</span>, <span class="php-string">&quot;.&quot;</span>, <span class="php-string">&quot;,&quot;</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">&quot; and &quot;</span> <span class="php-operator">.</span> <span class="php-function">number_format</span><span class="php-brackets">(</span><span class="php-var">$max_size</span>, <span class="php-number">0</span>, <span class="php-string">&quot;.&quot;</span>, <span class="php-string">&quot;,&quot;</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">&quot; exclussive.&quot;</span>;
			<span class="php-brackets">}</span>
			<span class="php-keyword">return</span> <span class="php-var">$string</span>;
		<span class="php-brackets">}</span>

		<span class="php-function">function</span> get_bd_amount_in_text<span class="php-brackets">(</span><span class="php-var">$amount</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-var">$output_string</span> <span class="php-operator">=</span> <span class="php-string">''</span>;

			<span class="php-var">$tokens</span> <span class="php-operator">=</span> <span class="php-function">explode</span><span class="php-brackets">(</span><span class="php-string">'.'</span>, <span class="php-var">$amount</span><span class="php-brackets">)</span>;
			<span class="php-var">$current_amount</span> <span class="php-operator">=</span> <span class="php-var">$tokens</span><span class="php-brackets">[</span><span class="php-number">0</span><span class="php-brackets">]</span>;
			<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-function">count</span><span class="php-brackets">(</span><span class="php-var">$tokens</span><span class="php-brackets">)</span> <span class="php-operator">&gt;</span> <span class="php-number">1</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-brackets">(</span>double<span class="php-brackets">)</span><span class="php-brackets">(</span><span class="php-string">'0.'</span> <span class="php-operator">.</span> <span class="php-var">$tokens</span><span class="php-brackets">[</span><span class="php-number">1</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
				<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-var">$fraction</span> <span class="php-operator">*</span> <span class="php-number">1</span><span class="php-number">0</span><span class="php-number">0</span>;
				<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-function">round</span><span class="php-brackets">(</span><span class="php-var">$fraction</span>, <span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-brackets">(</span><span class="php-var-type">int</span><span class="php-brackets">)</span><span class="php-var">$fraction</span>;
				<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-var">$fraction</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">' paisa'</span>;
				<span class="php-var">$fraction</span> <span class="php-operator">=</span> <span class="php-string">' Taka &amp; '</span> <span class="php-operator">.</span> <span class="php-var">$fraction</span>;
			<span class="php-brackets">}</span>

			<span class="php-var">$crore</span> <span class="php-operator">=</span> <span class="php-number">0</span>;
			<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-var">$current_amount</span> <span class="php-operator">&gt;</span><span class="php-operator">=</span> <span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">7</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-var">$crore</span> <span class="php-operator">=</span> <span class="php-brackets">(</span><span class="php-var-type">int</span><span class="php-brackets">)</span><span class="php-function">floor</span><span class="php-brackets">(</span><span class="php-var">$current_amount</span> <span class="php-operator">/</span> <span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">7</span><span class="php-brackets">)</span><span class="php-brackets">)</span>;
				<span class="php-var">$output_string</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-var">$crore</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">' crore '</span>;
				<span class="php-var">$current_amount</span> <span class="php-operator">=</span> <span class="php-var">$current_amount</span> <span class="php-operator">-</span> <span class="php-var">$crore</span> <span class="php-operator">*</span> <span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">7</span><span class="php-brackets">)</span>;
			<span class="php-brackets">}</span>

			<span class="php-var">$lakh</span> <span class="php-operator">=</span> <span class="php-number">0</span>;
			<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-var">$current_amount</span> <span class="php-operator">&gt;</span><span class="php-operator">=</span> <span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">5</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-var">$lakh</span> <span class="php-operator">=</span> <span class="php-brackets">(</span><span class="php-var-type">int</span><span class="php-brackets">)</span><span class="php-function">floor</span><span class="php-brackets">(</span><span class="php-var">$current_amount</span> <span class="php-operator">/</span> <span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">5</span><span class="php-brackets">)</span><span class="php-brackets">)</span>;
				<span class="php-var">$output_string</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-var">$lakh</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">' lakh '</span>;
				<span class="php-var">$current_amount</span> <span class="php-operator">=</span> <span class="php-var">$current_amount</span> <span class="php-operator">-</span> <span class="php-var">$lakh</span> <span class="php-operator">*</span> <span class="php-function">pow</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span>,<span class="php-number">5</span><span class="php-brackets">)</span>;
			<span class="php-brackets">}</span>

			<span class="php-var">$current_amount</span> <span class="php-operator">=</span> <span class="php-brackets">(</span><span class="php-var-type">int</span><span class="php-brackets">)</span><span class="php-var">$current_amount</span>;
			<span class="php-var">$output_string</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>translate_to_words<span class="php-brackets">(</span><span class="php-var">$current_amount</span><span class="php-brackets">)</span>;

			<span class="php-var">$output_string</span> <span class="php-operator">=</span> <span class="php-var">$output_string</span> <span class="php-operator">.</span> <span class="php-var">$fraction</span> <span class="php-operator">.</span> <span class="php-string">' only'</span>;
			<span class="php-var">$output_string</span> <span class="php-operator">=</span> <span class="php-function">ucwords</span><span class="php-brackets">(</span><span class="php-var">$output_string</span><span class="php-brackets">)</span>;
			<span class="php-keyword">return</span> <span class="php-var">$output_string</span>;
		<span class="php-brackets">}</span>

	<span class="php-brackets">}</span>

	<span class="php-var">$currency_object</span> <span class="php-operator">=</span> <span class="php-keyword">new</span> Currency<span class="php-brackets">(</span><span class="php-brackets">)</span>;

	<span class="php-keyword">for</span><span class="php-brackets">(</span><span class="php-var">$i</span><span class="php-operator">=</span><span class="php-number">1</span>; <span class="php-var">$i</span><span class="php-operator">&lt;</span><span class="php-number">1</span><span class="php-number">0</span>; <span class="php-var">$i</span><span class="php-operator">+</span><span class="php-operator">+</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-var">$seed</span> <span class="php-operator">=</span> <span class="php-function">time</span><span class="php-brackets">(</span><span class="php-brackets">)</span> <span class="php-operator">/</span> <span class="php-brackets">(</span><span class="php-var">$i</span> <span class="php-operator">+</span> <span class="php-number">1</span><span class="php-brackets">)</span>;
		<span class="php-function">srand</span><span class="php-brackets">(</span><span class="php-var">$seed</span><span class="php-brackets">)</span>;
		<span class="php-var">$amount</span> <span class="php-operator">=</span> <span class="php-function">mt_rand</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-number">0</span>, <span class="php-number">9</span><span class="php-number">9</span><span class="php-number">9</span><span class="php-number">9</span><span class="php-number">9</span><span class="php-number">9</span><span class="php-number">9</span><span class="php-brackets">)</span>;
		<span class="php-var">$amount</span> <span class="php-operator">=</span> <span class="php-var">$amount</span> <span class="php-operator">+</span> <span class="php-var">$i</span><span class="php-operator">/</span><span class="php-number">1</span><span class="php-number">0</span>;
		<span class="php-keyword">echo</span> <span class="php-var">$currency_object</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>get_bd_money_format<span class="php-brackets">(</span><span class="php-var">$amount</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">' : '</span> <span class="php-operator">.</span> <span class="php-var">$currency_object</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>get_bd_amount_in_text<span class="php-brackets">(</span><span class="php-var">$amount</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;

	<span class="php-brackets">}</span>

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>Sample Output:</p>
<p>================================================</p>
<div id="_mcePaste">84,20,202.10 : Eighty Four Lakh Twenty Thousand Two Hundred And Two Taka &amp; Ten Paisa Only</div>
<div id="_mcePaste">10,90,495.20 : Ten Lakh Ninety Thousand Four Hundred And Ninety Five Taka &amp; Twenty Paisa Only</div>
<div id="_mcePaste">12,51,706.30 : Twelve Lakh Fifty One Thousand Seven Hundred And Six Taka &amp; Thirty Paisa Only</div>
<div id="_mcePaste">78,31,550.40 : Seventy Eight Lakh Thirty One Thousand Five Hundred And Fifty Taka &amp; Forty Paisa Only</div>
<div id="_mcePaste">49,59,035.50 : Forty Nine Lakh Fifty Nine Thousand Thirty Five Taka &amp; Fifty Paisa Only</div>
<div id="_mcePaste">29,83,538.60 : Twenty Nine Lakh Eighty Three Thousand Five Hundred And Thirty Eight Taka &amp; Sixty Paisa Only</div>
<div id="_mcePaste">50,70,303.70 : Fifty Lakh Seventy Thousand Three Hundred And Three Taka &amp; Seventy Paisa Only</div>
<div id="_mcePaste">11,98,440.80 : Eleven Lakh Ninety Eight Thousand Four Hundred And Forty Taka &amp; Eighty Paisa Only</div>
<div id="_mcePaste">70,08,871.90 : Seventy Lakh Eight Thousand Eight Hundred And Seventy One Taka &amp; Ninety Paisa Only</div>
<p>================================================</p>
<p>That&#8217;s it!</p>
<p>Please feel free to use this code anytime anywhere.</p>
<p>If you update/enhance this code, please share with other people.</p>
<p>Thanks for reading.</p>
<p><map name='google_ad_map_112_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/112?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_112_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=112&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2011%2F01%2F28%2Fphp-convert-number-currency-to-text-in-asian-i-e-bangladeshi-indian-format%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2011/01/28/php-convert-number-currency-to-text-in-asian-i-e-bangladeshi-indian-format/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>JavaScript: Div &amp; Element hide &amp; show cross-browser script solution</title>
		<link>http://www.tanzilo.com/2009/01/17/javascript-div-element-hide-show-cross-browser-script-solution/</link>
		<comments>http://www.tanzilo.com/2009/01/17/javascript-div-element-hide-show-cross-browser-script-solution/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 22:17:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cross-browser]]></category>
		<category><![CDATA[DIV]]></category>
		<category><![CDATA[Element]]></category>
		<category><![CDATA[hide]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[show]]></category>
		<category><![CDATA[solution]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=75</guid>
		<description><![CDATA[Hello Guys, Today I was working in a project where I had to add element hide and show depending on the condition. For example, if the client wants to contact by phone, the phone DIV element or area appears. If not, the phone DIV element hide quickly. I was writing scripts for this. But to [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Guys,</p>
<p>Today I was working in a project where I had to add element hide and show depending on the condition. For example, if the client wants to contact by phone, the phone DIV element or area appears. If not, the phone DIV element hide quickly. I was writing scripts for this. But to my surprise, I noticed that none of them are cross-browser supporting. When one scripting working in few browsers, the same script is not working in other browsers. So, I struggled to come up with the cross-browser solution and at last, I succeeded. You can use this code in your form whenever you need to show and hide elements dynamically in JavaScript. This script is a kind of Contact Us form.</p>
<p>So, what am I gonna do? I am going to share my small script so that you can save your time I you find my this article by Google search or any other search.</p>
<p>OK!<br />
No more introduction. Let us start.</p>
<p><span style="text-decoration: underline;"><strong>Download:</strong></span></p>
<p>I suggest you first download the script and take a look.<br />
<a title="JavaScript Hide &amp; Show/Display" href="http://www.tanzilo.com/demo/code/hide_show/hide_show.zip" target="_blank">http://www.tanzilo.com/demo/code/hide_show/hide_show.zip</a></p>
<p><span style="text-decoration: underline;"><strong>Features:</strong></span></p>
<ol>
<li>It is a totally CSS-based and table-less scripting</li>
<li>I have used phpMailer version 2.3 and it works for PHP 5 and/or 6 version</li>
<li>JavaScript used as you already know</li>
</ol>
<p><span style="text-decoration: underline;"><strong>CSS Code:</strong></span></p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="css">&lt;style type=<span class="css-string">&quot;text/css&quot;</span>&gt;
	body
	{
		<span class="css-property">font-family<span class="css-selector">:</span><span class="css-value">Tahoma, Verdana, Arial, Helvetica, sans-serif</span></span>;
		<span class="css-property">font-size<span class="css-selector">:</span><span class="css-value">12px</span></span>;
	}
	#contactForm
	{
		<span class="css-property">width<span class="css-selector">:</span><span class="css-value">500px</span></span>; <span class="css-property">height<span class="css-selector">:</span><span class="css-value">auto</span></span>; <span class="css-property">float<span class="css-selector">:</span><span class="css-value">left</span></span>; <span class="css-property">clear<span class="css-selector">:</span><span class="css-value">both</span></span>;
	}
	#contactForm INPUT, OPTION, TEXTAREA
	{
		<span class="css-property">font-family<span class="css-selector">:</span><span class="css-value">Tahoma, Verdana, Arial, Helvetica, sans-serif</span></span>;
		<span class="css-property">font-size<span class="css-selector">:</span><span class="css-value">12px</span></span>;
	}
	#formRow
	{
		<span class="css-property">width<span class="css-selector">:</span><span class="css-value">500px</span></span>; <span class="css-property">float<span class="css-selector">:</span><span class="css-value">left</span></span>; <span class="css-property">padding<span class="css-selector">:</span><span class="css-value">3px 0px 0px 0px</span></span>;
	}
	#columnLeft
	{
		<span class="css-property">width<span class="css-selector">:</span><span class="css-value">250px</span></span>; <span class="css-property">height<span class="css-selector">:</span><span class="css-value">auto</span></span>; <span class="css-property">float<span class="css-selector">:</span><span class="css-value">left</span></span>;
	}
	#columnRight
	{
		<span class="css-property">width<span class="css-selector">:</span><span class="css-value">250px</span></span>; <span class="css-property">height<span class="css-selector">:</span><span class="css-value">auto</span></span>; <span class="css-property">float<span class="css-selector">:</span><span class="css-value">left</span></span>;
	}
	#formOutput
	{
	}
	#errorMessage
	{
		<span class="css-property">color<span class="css-selector">:</span><span class="css-value">#FF0000</span></span>; <span class="css-property">font-weight<span class="css-selector">:</span><span class="css-value">bold</span></span>;
	}
	#successMessage
	{
		<span class="css-property">color<span class="css-selector">:</span><span class="css-value">#009900</span></span>; <span class="css-property">font-weight<span class="css-selector">:</span><span class="css-value">bold</span></span>;
	}
	#formRowForum
	{
		<span class="css-property">width<span class="css-selector">:</span><span class="css-value">500px</span></span>; <span class="css-property">float<span class="css-selector">:</span><span class="css-value">left</span></span>; <span class="css-property">padding<span class="css-selector">:</span><span class="css-value">3px 0px 0px 0px</span></span>;
	}
	#formRowDatabase
	{
		<span class="css-property">width<span class="css-selector">:</span><span class="css-value">500px</span></span>; <span class="css-property">float<span class="css-selector">:</span><span class="css-value">left</span></span>; <span class="css-property">padding<span class="css-selector">:</span><span class="css-value">3px 0px 0px 0px</span></span>;
	}
	#formRowUsers
	{
		<span class="css-property">width<span class="css-selector">:</span><span class="css-value">500px</span></span>; <span class="css-property">float<span class="css-selector">:</span><span class="css-value">left</span></span>; <span class="css-property">padding<span class="css-selector">:</span><span class="css-value">3px 0px 0px 0px</span></span>;
	}
	#formRowProvider
	{
		<span class="css-property">width<span class="css-selector">:</span><span class="css-value">500px</span></span>; <span class="css-property">float<span class="css-selector">:</span><span class="css-value">left</span></span>; <span class="css-property">padding<span class="css-selector">:</span><span class="css-value">3px 0px 0px 0px</span></span>;
	}
	#formRowCurrentSpecs
	{
		<span class="css-property">width<span class="css-selector">:</span><span class="css-value">500px</span></span>; <span class="css-property">float<span class="css-selector">:</span><span class="css-value">left</span></span>; <span class="css-property">padding<span class="css-selector">:</span><span class="css-value">3px 0px 0px 0px</span></span>;
	}
&lt;/style&gt;</span></pre>
</div>
<p><span style="text-decoration: underline;"><strong>HTML Code:</strong></span></p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="html"><span class="html-form-element">&lt;form id=<span class="html-attribute">&quot;contact_form&quot;</span> name=<span class="html-attribute">&quot;contact_form&quot;</span> method=<span class="html-attribute">&quot;post&quot;</span> action=<span class="html-attribute">&quot;&quot;</span>&gt;</span>
    <span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;contactForm&quot;</span>&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRow&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Name:<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span><span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;name&quot;</span> type=<span class="html-attribute">&quot;text&quot;</span> value=<span class="html-attribute">&quot;&lt;?php echo $_SESSION['name']; ?</span>&gt;</span>&quot; /&gt;<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRow&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Email:<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span><span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;email&quot;</span> type=<span class="html-attribute">&quot;text&quot;</span> value=<span class="html-attribute">&quot;&lt;?php echo $_SESSION['email']; ?</span>&gt;</span>&quot; /&gt;<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRow&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Best method to contact you:<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span>
            	<span class="html-form-element">&lt;select name=<span class="html-attribute">&quot;contact_method&quot;</span> id=<span class="html-attribute">&quot;contact_method&quot;</span> onchange=<span class="html-attribute">&quot;displayContactMethod();&quot;</span>&gt;</span>
          			<span class="html-form-element">&lt;option value=<span class="html-attribute">&quot;Please Select One&quot;</span>&gt;</span>Please Select One<span class="html-form-element">&lt;/option&gt;</span>
          			<span class="html-form-element">&lt;option value=<span class="html-attribute">&quot;Phone&quot;</span>&gt;</span>Phone<span class="html-form-element">&lt;/option&gt;</span>
        		<span class="html-form-element">&lt;/select&gt;</span>
                <span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;phoneNoDiv&quot;</span>&gt;</span>Phone No: <span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;phone&quot;</span> id=<span class="html-attribute">&quot;phone&quot;</span> type=<span class="html-attribute">&quot;text&quot;</span> value=<span class="html-attribute">&quot;&lt;?php echo $_SESSION['phone'] ;?</span>&gt;</span>&quot; /&gt;<span class="html-other-element">&lt;/div&gt;</span>
			<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRow&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Will this server host a vBulletin site?<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span>
            	<span class="html-form-element">&lt;select name=<span class="html-attribute">&quot;host_vb&quot;</span> id=<span class="html-attribute">&quot;host_vb&quot;</span> onchange=<span class="html-attribute">&quot;controlServerHostOptions();&quot;</span>&gt;</span>
          			<span class="html-form-element">&lt;option value=<span class="html-attribute">&quot;No&quot;</span>&gt;</span>No<span class="html-form-element">&lt;/option&gt;</span>
          			<span class="html-form-element">&lt;option value=<span class="html-attribute">&quot;Yes&quot;</span>&gt;</span>Yes<span class="html-form-element">&lt;/option&gt;</span>
        		<span class="html-form-element">&lt;/select&gt;</span>
			<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRowForum&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Forum Link:<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span><span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;forum_link&quot;</span> type=<span class="html-attribute">&quot;text&quot;</span> value=<span class="html-attribute">&quot;&lt;?php echo $_SESSION['forum_link'] ;?</span>&gt;</span>&quot; /&gt;<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRowDatabase&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Current size of database:<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span><span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;size&quot;</span> type=<span class="html-attribute">&quot;text&quot;</span> value=<span class="html-attribute">&quot;&lt;?php echo $_SESSION['size']; ?</span>&gt;</span>&quot; /&gt;<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRowUsers&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Average concurrent users:<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span><span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;users&quot;</span> type=<span class="html-attribute">&quot;text&quot;</span> value=<span class="html-attribute">&quot;&lt;?php echo $_SESSION['users']; ?</span>&gt;</span>&quot; /&gt;<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRow&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Do you currently have a dedicated server?<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span>
            	<span class="html-form-element">&lt;select name=<span class="html-attribute">&quot;server&quot;</span> id=<span class="html-attribute">&quot;server&quot;</span> onchange=<span class="html-attribute">&quot;controlCurrentHostOptions();&quot;</span>&gt;</span>
          			<span class="html-form-element">&lt;option value=<span class="html-attribute">&quot;No&quot;</span>&gt;</span>No<span class="html-form-element">&lt;/option&gt;</span>
          			<span class="html-form-element">&lt;option value=<span class="html-attribute">&quot;Yes&quot;</span>&gt;</span>Yes<span class="html-form-element">&lt;/option&gt;</span>
        		<span class="html-form-element">&lt;/select&gt;</span>
			<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRowProvider&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Current Provider:<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span><span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;current_provider&quot;</span> type=<span class="html-attribute">&quot;text&quot;</span> value=<span class="html-attribute">&quot;&lt;?php echo $_SESSION['current_provider']; ?</span>&gt;</span>&quot; /&gt;<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRowCurrentSpecs&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Current Server Specs:<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span><span class="html-form-element">&lt;textarea name=<span class="html-attribute">&quot;current_specs&quot;</span> cols=<span class="html-attribute">&quot;30&quot;</span> rows=<span class="html-attribute">&quot;5&quot;</span>&gt;</span><span class="html-other-element">&lt;?php echo $_SESSION[<span class="html-attribute">'current_specs'</span>] ;?&gt;</span><span class="html-form-element">&lt;/textarea&gt;</span><span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRow&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Are there any specs you must have with your new server
            or additional notes you would like us to consider?<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span><span class="html-form-element">&lt;textarea name=<span class="html-attribute">&quot;specs&quot;</span> cols=<span class="html-attribute">&quot;30&quot;</span> rows=<span class="html-attribute">&quot;5&quot;</span>&gt;</span><span class="html-other-element">&lt;?php echo $_SESSION[<span class="html-attribute">'specs'</span>]; ?&gt;</span><span class="html-form-element">&lt;/textarea&gt;</span><span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRow&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Time frame to purchase<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span><span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;time&quot;</span> type=<span class="html-attribute">&quot;text&quot;</span> value=<span class="html-attribute">&quot;&lt;?php echo $_SESSION['time']; ?</span>&gt;</span>&quot; /&gt;<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRow&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Do you have a budget we need to consider?<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span><span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;budget&quot;</span> type=<span class="html-attribute">&quot;text&quot;</span> value=<span class="html-attribute">&quot;&lt;?php echo $_SESSION['budget']; ?</span>&gt;</span>&quot; /&gt;<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRow&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span>Anti Spam Question: How much is: 5+5+3=?<span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span><span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;total&quot;</span> type=<span class="html-attribute">&quot;text&quot;</span> /&gt;</span><span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;formRow&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnLeft&quot;</span>&gt;</span><span class="html-special-char">&amp;nbsp;</span><span class="html-other-element">&lt;/div&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;columnRight&quot;</span>&gt;</span>
            	<span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;submit&quot;</span> type=<span class="html-attribute">&quot;submit&quot;</span> value=<span class="html-attribute">&quot;Submit&quot;</span> /&gt;</span>
                <span class="html-form-element">&lt;input name=<span class="html-attribute">&quot;reset&quot;</span> type=<span class="html-attribute">&quot;reset&quot;</span> /&gt;</span>
        	<span class="html-other-element">&lt;/div&gt;</span>
        <span class="html-other-element">&lt;/div&gt;</span>
    <span class="html-other-element">&lt;/div&gt;</span>
<span class="html-form-element">&lt;/form&gt;</span></span></pre>
</div>
<p><span style="text-decoration: underline;"><strong>JavaScript Code:</strong></span></p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
196
</pre>
<pre><span class="js"><span class="js-function-keyword">function</span> displayContactMethod<span class="js-bracket">(</span><span class="js-bracket">)</span>
	<span class="js-bracket">{</span>
		<span class="js-reserved-keyword">var</span> id <span class="js-operator">=</span> <span class="js-string">'phone'</span>;
		<span class="js-reserved-keyword">var</span> contatMethod <span class="js-operator">=</span> <span class="js-client-keyword">document</span>.contact_form.contact_method.value;

		<span class="js-reserved-keyword">if</span><span class="js-bracket">(</span>contatMethod <span class="js-operator">=</span><span class="js-operator">=</span> <span class="js-string">&quot;Phone&quot;</span><span class="js-bracket">)</span>
		<span class="js-bracket">{</span>
			displayDiv<span class="js-bracket">(</span><span class="js-string">'phoneNoDiv'</span><span class="js-bracket">)</span>
		<span class="js-bracket">}</span>
		<span class="js-reserved-keyword">else</span>
		<span class="js-bracket">{</span>
			hideDiv<span class="js-bracket">(</span><span class="js-string">'phoneNoDiv'</span><span class="js-bracket">)</span>;
			<span class="js-client-keyword">document</span>.contact_form.phone.value <span class="js-operator">=</span> <span class="js-string">''</span>;
		<span class="js-bracket">}</span>
	<span class="js-bracket">}</span>

	<span class="js-function-keyword">function</span> initialHiddenDivs<span class="js-bracket">(</span><span class="js-bracket">)</span>
	<span class="js-bracket">{</span>
		<span class="js-reserved-keyword">var</span> divID_<span class="js-number">1</span> <span class="js-operator">=</span> <span class="js-string">'phoneNoDiv'</span>;
		<span class="js-reserved-keyword">var</span> divID_<span class="js-number">2</span> <span class="js-operator">=</span> <span class="js-string">'formRowForum'</span>;
		<span class="js-reserved-keyword">var</span> divID_<span class="js-number">3</span> <span class="js-operator">=</span> <span class="js-string">'formRowDatabase'</span>;
		<span class="js-reserved-keyword">var</span> divID_<span class="js-number">4</span> <span class="js-operator">=</span> <span class="js-string">'formRowUsers'</span>;
		<span class="js-reserved-keyword">var</span> divID_<span class="js-number">5</span> <span class="js-operator">=</span> <span class="js-string">'formRowProvider'</span>;
		<span class="js-reserved-keyword">var</span> divID_<span class="js-number">6</span> <span class="js-operator">=</span> <span class="js-string">'formRowCurrentSpecs'</span>;

		hideDiv<span class="js-bracket">(</span>divID_<span class="js-number">1</span><span class="js-bracket">)</span>;
		hideDiv<span class="js-bracket">(</span>divID_<span class="js-number">2</span><span class="js-bracket">)</span>;
		hideDiv<span class="js-bracket">(</span>divID_<span class="js-number">3</span><span class="js-bracket">)</span>;
		hideDiv<span class="js-bracket">(</span>divID_<span class="js-number">4</span><span class="js-bracket">)</span>;
		hideDiv<span class="js-bracket">(</span>divID_<span class="js-number">5</span><span class="js-bracket">)</span>;
		hideDiv<span class="js-bracket">(</span>divID_<span class="js-number">6</span><span class="js-bracket">)</span>;
	<span class="js-bracket">}</span>
	<span class="js-function-keyword">function</span> hideDiv<span class="js-bracket">(</span>id<span class="js-bracket">)</span>
	<span class="js-bracket">{</span>
		<span class="js-reserved-keyword">if</span> <span class="js-bracket">(</span><span class="js-client-keyword">document</span>.getElementById<span class="js-bracket">)</span> <span class="js-bracket">{</span> <span class="js-comment">// DOM3 = IE5, NS6
</span>
			<span class="js-client-keyword">document</span>.getElementById<span class="js-bracket">(</span>id<span class="js-bracket">)</span>.style.display <span class="js-operator">=</span> <span class="js-string">'none'</span>;
		<span class="js-bracket">}</span>
		<span class="js-reserved-keyword">else</span> <span class="js-bracket">{</span>
			<span class="js-reserved-keyword">if</span> <span class="js-bracket">(</span><span class="js-client-keyword">document</span>.layers<span class="js-bracket">)</span> <span class="js-bracket">{</span> <span class="js-comment">// Netscape 4
</span>
				<span class="js-client-keyword">document</span>.id.display <span class="js-operator">=</span> <span class="js-string">'none'</span>;
			<span class="js-bracket">}</span>
			<span class="js-reserved-keyword">else</span> <span class="js-bracket">{</span> <span class="js-comment">// IE 4
</span>
				<span class="js-client-keyword">document</span>.<span class="js-client-keyword">all</span>.id.style.display <span class="js-operator">=</span> <span class="js-string">'none'</span>;
			<span class="js-bracket">}</span>
		<span class="js-bracket">}</span>
	<span class="js-bracket">}</span>

	<span class="js-function-keyword">function</span> displayDiv<span class="js-bracket">(</span>id<span class="js-bracket">)</span>
	<span class="js-bracket">{</span>
		<span class="js-reserved-keyword">if</span> <span class="js-bracket">(</span><span class="js-client-keyword">document</span>.getElementById<span class="js-bracket">)</span> <span class="js-bracket">{</span> <span class="js-comment">// DOM3 = IE5, NS6
</span>
			<span class="js-client-keyword">document</span>.getElementById<span class="js-bracket">(</span>id<span class="js-bracket">)</span>.style.display <span class="js-operator">=</span> <span class="js-string">'block'</span>;
		<span class="js-bracket">}</span>
		<span class="js-reserved-keyword">else</span> <span class="js-bracket">{</span>
			<span class="js-reserved-keyword">if</span> <span class="js-bracket">(</span><span class="js-client-keyword">document</span>.layers<span class="js-bracket">)</span> <span class="js-bracket">{</span> <span class="js-comment">// Netscape 4
</span>
				<span class="js-client-keyword">document</span>.id.display <span class="js-operator">=</span> <span class="js-string">'block'</span>;
			<span class="js-bracket">}</span>
			<span class="js-reserved-keyword">else</span> <span class="js-bracket">{</span> <span class="js-comment">// IE 4
</span>
				<span class="js-client-keyword">document</span>.<span class="js-client-keyword">all</span>.id.style.display <span class="js-operator">=</span> <span class="js-string">'block'</span>;
			<span class="js-bracket">}</span>
		<span class="js-bracket">}</span>
	<span class="js-bracket">}</span>

	<span class="js-function-keyword">function</span> controlServerHostOptions<span class="js-bracket">(</span><span class="js-bracket">)</span>
	<span class="js-bracket">{</span>
		<span class="js-reserved-keyword">var</span> host_vb <span class="js-operator">=</span> <span class="js-client-keyword">document</span>.contact_form.host_vb.value;

		<span class="js-reserved-keyword">if</span><span class="js-bracket">(</span>host_vb <span class="js-operator">=</span><span class="js-operator">=</span> <span class="js-string">&quot;Yes&quot;</span><span class="js-bracket">)</span>
		<span class="js-bracket">{</span>
			displayDiv<span class="js-bracket">(</span><span class="js-string">'formRowForum'</span><span class="js-bracket">)</span>;
			displayDiv<span class="js-bracket">(</span><span class="js-string">'formRowDatabase'</span><span class="js-bracket">)</span>;
			displayDiv<span class="js-bracket">(</span><span class="js-string">'formRowUsers'</span><span class="js-bracket">)</span>;
		<span class="js-bracket">}</span>
		<span class="js-reserved-keyword">else</span>
		<span class="js-bracket">{</span>
			hideDiv<span class="js-bracket">(</span><span class="js-string">'formRowForum'</span><span class="js-bracket">)</span>;
			hideDiv<span class="js-bracket">(</span><span class="js-string">'formRowDatabase'</span><span class="js-bracket">)</span>;
			hideDiv<span class="js-bracket">(</span><span class="js-string">'formRowUsers'</span><span class="js-bracket">)</span>;
			<span class="js-client-keyword">document</span>.contact_form.forum_link.value <span class="js-operator">=</span> <span class="js-string">''</span>;
			<span class="js-client-keyword">document</span>.contact_form.size.value <span class="js-operator">=</span> <span class="js-string">''</span>;
			<span class="js-client-keyword">document</span>.contact_form.users.value <span class="js-operator">=</span> <span class="js-string">''</span>;
		<span class="js-bracket">}</span>
	<span class="js-bracket">}</span>

	<span class="js-function-keyword">function</span> controlCurrentHostOptions<span class="js-bracket">(</span><span class="js-bracket">)</span>
	<span class="js-bracket">{</span>
		<span class="js-reserved-keyword">var</span> server <span class="js-operator">=</span> <span class="js-client-keyword">document</span>.contact_form.server.value;

		<span class="js-reserved-keyword">if</span><span class="js-bracket">(</span>server <span class="js-operator">=</span><span class="js-operator">=</span> <span class="js-string">&quot;Yes&quot;</span><span class="js-bracket">)</span>
		<span class="js-bracket">{</span>
			displayDiv<span class="js-bracket">(</span><span class="js-string">'formRowProvider'</span><span class="js-bracket">)</span>;
			displayDiv<span class="js-bracket">(</span><span class="js-string">'formRowCurrentSpecs'</span><span class="js-bracket">)</span>;
		<span class="js-bracket">}</span>
		<span class="js-reserved-keyword">else</span>
		<span class="js-bracket">{</span>
			hideDiv<span class="js-bracket">(</span><span class="js-string">'formRowProvider'</span><span class="js-bracket">)</span>;
			hideDiv<span class="js-bracket">(</span><span class="js-string">'formRowCurrentSpecs'</span><span class="js-bracket">)</span>;
			<span class="js-client-keyword">document</span>.contact_form.current_provider.value <span class="js-operator">=</span> <span class="js-string">''</span>;
			<span class="js-client-keyword">document</span>.contact_form.current_specs.value <span class="js-operator">=</span> <span class="js-string">''</span>;
		<span class="js-bracket">}</span>
	<span class="js-bracket">}</span></span></pre>
</div>
<p><span style="text-decoration: underline;"><strong>PHP Code:</strong></span></p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>		

		<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>

			<span class="php-var">$name</span> 				<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'name'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$email</span> 				<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'email'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$contact_method</span> 	<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'contact_method'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$phone</span> 				<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'phone'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$host_vb</span> 			<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'host_vb'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$forum_link</span> 		<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'forum_link'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$size</span> 				<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'size'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$users</span> 				<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'users'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$server</span> 			<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'server'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$current_provider</span> 	<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'current_provider'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$current_specs</span> 		<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'current_specs'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$specs</span> 				<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'specs'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$time</span> 				<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'time'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$budget</span> 			<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'budget'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
			<span class="php-var">$total</span>	 			<span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'total'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;

			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'name'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-var">$name</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'email'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-var">$email</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'contact_method'</span><span class="php-brackets">]</span>		<span class="php-operator">=</span> <span class="php-var">$contact_method</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'phone'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-var">$phone</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'host_vb'</span><span class="php-brackets">]</span>			<span class="php-operator">=</span> <span class="php-var">$host_vb</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'forum_link'</span><span class="php-brackets">]</span>			<span class="php-operator">=</span> <span class="php-var">$forum_link</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'size'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-var">$size</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'users'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-var">$users</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'server'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-var">$server</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'current_provider'</span><span class="php-brackets">]</span>	<span class="php-operator">=</span> <span class="php-var">$current_provider</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'current_specs'</span><span class="php-brackets">]</span>		<span class="php-operator">=</span> <span class="php-var">$current_specs</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'specs'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-var">$specs</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'time'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-var">$time</span>;
			<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'budget'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-var">$budget</span>;

			<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-var">$total</span> <span class="php-operator">!</span><span class="php-operator">=</span> <span class="php-number">1</span><span class="php-number">3</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
					<span class="php-keyword">echo</span> <span class="php-string">'&lt;div id=errorMessage&gt;Anti Spam Question is wrong!&lt;br /&gt;
					Please sum up and type the current result of: 5+5+3=?&lt;/div&gt;'</span>;
			<span class="php-brackets">}</span>
			<span class="php-keyword">else</span>
			<span class="php-brackets">{</span>

				<span class="php-var">$emailBody</span> <span class="php-operator">=</span> <span class="php-string">''</span>;
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$name</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Name : '</span> <span class="php-operator">.</span> <span class="php-var">$name</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$email</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Email : '</span> <span class="php-operator">.</span> <span class="php-var">$email</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$contact_method</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Best method to contact you : '</span> <span class="php-operator">.</span> <span class="php-var">$contact_method</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$phone</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Phone : '</span> <span class="php-operator">.</span> <span class="php-var">$phone</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$host_vb</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Will this server host a vBulletin site? : '</span> <span class="php-operator">.</span> <span class="php-var">$host_vb</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$forum_link</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Forum Link : '</span> <span class="php-operator">.</span> <span class="php-var">$forum_link</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$size</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Current size of database : '</span> <span class="php-operator">.</span> <span class="php-var">$size</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$users</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Average concurrent users : '</span> <span class="php-operator">.</span> <span class="php-var">$users</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$server</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Do you currently have a dedicated server? : '</span> <span class="php-operator">.</span> <span class="php-var">$server</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$current_provider</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Current Provider : '</span> <span class="php-operator">.</span> <span class="php-var">$current_provider</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$current_specs</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Current Server Specs : '</span> <span class="php-operator">.</span> <span class="php-var">$current_specs</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$specs</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Are there any specs you must have with your
								   new server or additional notes you would
								   like us to consider? : '</span> <span class="php-operator">.</span> <span class="php-var">$specs</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$time</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Time frame to purchase : '</span> <span class="php-operator">.</span> <span class="php-var">$time</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$budget</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$emailBody</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'Do you have a budget we need to consider? : '</span> <span class="php-operator">.</span> <span class="php-var">$budget</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>

				<span class="php-keyword">include_once</span><span class="php-brackets">(</span><span class="php-string">'php5Mailer/class.phpmailer.php'</span><span class="php-brackets">)</span>;

				<span class="php-var">$mail</span> <span class="php-operator">=</span> <span class="php-keyword">new</span> PHPMailer<span class="php-brackets">(</span><span class="php-brackets">)</span>;

				<span class="php-var">$body</span> <span class="php-operator">=</span> <span class="php-var">$emailBody</span>;
				<span class="php-var">$body</span> <span class="php-operator">=</span> <span class="php-function">eregi_replace</span><span class="php-brackets">(</span><span class="php-string">&quot;[\]&quot;</span>,<span class="php-string">''</span>,<span class="php-var">$body</span><span class="php-brackets">)</span>;
				<span class="php-var">$subject</span> <span class="php-operator">=</span> <span class="php-function">eregi_replace</span><span class="php-brackets">(</span><span class="php-string">&quot;[\]&quot;</span>,<span class="php-string">''</span>,<span class="php-var">$subject</span><span class="php-brackets">)</span>;

				<span class="php-var">$mail</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>From <span class="php-operator">=</span> <span class="php-var">$email</span>;
				<span class="php-var">$mail</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>FromName <span class="php-operator">=</span> <span class="php-var">$name</span>;

				<span class="php-var">$mail</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>Subject <span class="php-operator">=</span> <span class="php-string">&quot;New Email from $name ($email)&quot;</span>;

				<span class="php-comment">// optional, comment out and test
</span>
				<span class="php-var">$mail</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>AltBody <span class="php-operator">=</span> <span class="php-string">&quot;To view the message, please use an HTML compatible email viewer!&quot;</span>; 

				<span class="php-var">$mail</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>Body <span class="php-operator">=</span> <span class="php-function">nl2br</span><span class="php-brackets">(</span><span class="php-var">$body</span><span class="php-brackets">)</span>;

				<span class="php-var">$mail</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>AddAddress<span class="php-brackets">(</span><span class="php-string">&quot;todd@urljet.com&quot;</span>, <span class="php-string">&quot;Todd&quot;</span><span class="php-brackets">)</span>;
				<span class="php-var">$mail</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>IsHTML<span class="php-brackets">(</span><span class="php-keyword">true</span><span class="php-brackets">)</span>;

				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-var">$mail</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>Send<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-keyword">echo</span> <span class="php-string">'&lt;div id=errorMessage&gt;Failed to send mail&lt;/div&gt;'</span>;
				<span class="php-brackets">}</span>
				<span class="php-keyword">else</span>
				<span class="php-brackets">{</span>
					<span class="php-keyword">echo</span> <span class="php-string">'&lt;div id=successMessage&gt;Mail sent&lt;/div&gt;'</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'name'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'email'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'contact_method'</span><span class="php-brackets">]</span>		<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'phone'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'host_vb'</span><span class="php-brackets">]</span>			<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'forum_link'</span><span class="php-brackets">]</span>			<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'size'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'users'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'server'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'current_provider'</span><span class="php-brackets">]</span>	<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'current_specs'</span><span class="php-brackets">]</span>		<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'specs'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'time'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-string">''</span>;
					<span class="php-var">$_SESSION</span><span class="php-brackets">[</span><span class="php-string">'budget'</span><span class="php-brackets">]</span>				<span class="php-operator">=</span> <span class="php-string">''</span>;
				<span class="php-brackets">}</span>	

			<span class="php-brackets">}</span>

		<span class="php-brackets">}</span>

	<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>Once again I would like to remind you that you first download this small script from the above download link and take a look at the whole script.</p>
<p>That is all for now, Dude!</p>
<p>Thank you for reading.</p>
<p><map name='google_ad_map_75_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/75?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_75_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=75&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2009%2F01%2F17%2Fjavascript-div-element-hide-show-cross-browser-script-solution%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2009/01/17/javascript-div-element-hide-show-cross-browser-script-solution/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>WordPress: adding a custom option box and developing file upload plugin</title>
		<link>http://www.tanzilo.com/2009/01/15/wordpress-adding-a-custom-option-box-and-developing-file-upload-plugin/</link>
		<comments>http://www.tanzilo.com/2009/01/15/wordpress-adding-a-custom-option-box-and-developing-file-upload-plugin/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 17:54:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[adding]]></category>
		<category><![CDATA[custom option box]]></category>
		<category><![CDATA[developing]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=70</guid>
		<description><![CDATA[Hello Buddy, One of my clients wanted to show thumbnail photo beside the post text as below. So, I had to make a plugin so that the admin can post the thumbnail when he is writing the post or can edit when editing the post. Take a look at the thumbnail&#8217;s position below. Thus, recently [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Buddy,</p>
<p>One of my clients wanted to show thumbnail photo beside the post text as below. So, I had to make a plugin so that the admin can post the thumbnail when he is writing the post or can edit when editing the post. Take a look at the thumbnail&#8217;s position below.</p>
<p><a href="http://www.tanzilo.com/wp-content/uploads/2009/01/bag-blog.jpg"><img class="alignleft size-full wp-image-72" style="float:none;" title="bag-blog" src="http://www.tanzilo.com/wp-content/uploads/2009/01/bag-blog.jpg" alt="" width="500" height="237" /></a></p>
<p>Thus, recently I solved a plugin problem in one of my wordpress works although it was small. You know you may sometimes need to add a custom field in your wordpress posting/writing/editing area. To check what I am saying, take a look at the following image:</p>
<p><a href="http://www.tanzilo.com/wp-content/uploads/2009/01/bag-thumbnail-plugin.jpg"><img class="alignleft size-full wp-image-71" style="float:none;" title="bag-thumbnail-plugin" src="http://www.tanzilo.com/wp-content/uploads/2009/01/bag-thumbnail-plugin.jpg" alt="" width="500" height="391" /></a></p>
<p>Adding such a box is extremely easy using the wordpress&#8217;s builtin <strong>add_meta</strong> function. But does file upload works i.e. if you upload the file, will it work? The answer is straight &#8211; &#8220;NO&#8221;. But why? The reason is also simple. If you want to upload a file, your form should have &#8220;<span style="text-decoration: underline;"><strong>enctype=&#8221;multipart/form-data</strong></span>&#8221; in the form opening such as</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="html"><span class="html-form-element">&lt;form name=<span class="html-attribute">&quot;post&quot;</span> action=<span class="html-attribute">&quot;post.php&quot;</span> method=<span class="html-attribute">&quot;post&quot;</span> id=<span class="html-attribute">&quot;post&quot;</span> enctype=<span class="html-attribute">&quot;multipart/form-data&quot;</span>&gt;</span></span></pre>
</div>
<p>But the problem is &#8211; if you open the source code of text editor tool as following,</p>
<p><a href="http://www.tanzilo.com/wp-content/uploads/2009/01/writing-editing-tool.jpg"><img class="alignleft size-full wp-image-73" style="float:none;" title="writing-editing-tool" src="http://www.tanzilo.com/wp-content/uploads/2009/01/writing-editing-tool.jpg" alt="" width="500" height="315" /></a></p>
<p>you will see that it does not have &#8220;<strong>enctype=&#8221;multipart/form-data</strong>&#8221; unfortunately. It looks exactly like this in my wordpress 2.7 version if I open the <span style="text-decoration: underline;">wp-admin/edit-form-advanced.php</span> file at line # 520.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="html"><span class="html-form-element">&lt;form name=<span class="html-attribute">&quot;post&quot;</span> action=<span class="html-attribute">&quot;post.php&quot;</span> method=<span class="html-attribute">&quot;post&quot;</span> id=<span class="html-attribute">&quot;post&quot;</span>&gt;</span></span></pre>
</div>
<p>Not funny? Huh?</p>
<p>So, to cope up with this situation, I had to add &#8220;<strong>enctype=&#8221;multipart/form-data</strong>&#8221; in the form although I do not like changing the core files. Why do not I like to change the core files? The answer simple. Because whenever there is an update, the client have to update the file everytime. The client may not like it or may even forget it. Anyway, after change, it looks like this:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="html"><span class="html-form-element">&lt;form name=<span class="html-attribute">&quot;post&quot;</span> action=<span class="html-attribute">&quot;post.php&quot;</span> method=<span class="html-attribute">&quot;post&quot;</span> id=<span class="html-attribute">&quot;post&quot;</span> enctype=<span class="html-attribute">&quot;multipart/form-data&quot;</span>&gt;</span></span></pre>
</div>
<p>OK. Lemme show you step by step what to do if you want to add a file upload plugin.</p>
<p><span style="text-decoration: underline;"><strong>Step One: Change the &#8220;wp-admin/edit-form-advanced.php&#8221; file</strong></span></p>
<p>Open this file from the mentioned location and change the following line in the file:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="html"><span class="html-form-element">&lt;form name=<span class="html-attribute">&quot;post&quot;</span> action=<span class="html-attribute">&quot;post.php&quot;</span> method=<span class="html-attribute">&quot;post&quot;</span> id=<span class="html-attribute">&quot;post&quot;</span>&gt;</span></span></pre>
</div>
<p>to this line:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="html"><span class="html-form-element">&lt;form name=<span class="html-attribute">&quot;post&quot;</span> action=<span class="html-attribute">&quot;post.php&quot;</span> method=<span class="html-attribute">&quot;post&quot;</span> id=<span class="html-attribute">&quot;post&quot;</span> enctype=<span class="html-attribute">&quot;multipart/form-data&quot;</span>&gt;</span></span></pre>
</div>
<p><span style="text-decoration: underline;"><strong>Step Two: Write you plugin</strong></span></p>
<p>Here goes mine:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>

	<span class="php-comment">/*
	Plugin Name: Bag Thumbnail
	Plugin URI: http://www.tanzilo.com/
	Description: This plugin helps you to set thumbnail image of your bags.
	Author: Tanzil Al Gazmir
	Version: 1.0
	Author URI: http://www.tanzilo.com/
	*/</span>

	<span class="php-function">function</span> init_bag_review_thumb_widget<span class="php-brackets">(</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>

		<span class="php-keyword">global</span> <span class="php-var">$wpdb</span>;

		<span class="php-var">$result</span> <span class="php-operator">=</span> <span class="php-function">mysql_list_tables</span><span class="php-brackets">(</span>DB_NAME<span class="php-brackets">)</span>;
		<span class="php-var">$current_table</span> <span class="php-operator">=</span> <span class="php-keyword">array</span><span class="php-brackets">(</span><span class="php-brackets">)</span>;
		<span class="php-keyword">while</span><span class="php-brackets">(</span><span class="php-var">$row</span> <span class="php-operator">=</span> <span class="php-function">mysql_fetch_row</span><span class="php-brackets">(</span><span class="php-var">$result</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-var">$current_tables</span><span class="php-brackets">[</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-var">$row</span><span class="php-brackets">[</span><span class="php-number">0</span><span class="php-brackets">]</span>;
		<span class="php-brackets">}</span>
		<span class="php-var">$myNewDatabaseTable</span> <span class="php-operator">=</span> <span class="php-var">$wpdb</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>prefix <span class="php-operator">.</span> <span class="php-string">'bag_thumb'</span>;
		<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-function">in_array</span><span class="php-brackets">(</span><span class="php-var">$myNewDatabaseTable</span>, <span class="php-var">$current_tables</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>

			<span class="php-function">mysql_query</span><span class="php-brackets">(</span><span class="php-string">&quot;
			CREATE TABLE IF NOT EXISTS `&quot;</span> <span class="php-operator">.</span> <span class="php-var">$myNewDatabaseTable</span> <span class="php-operator">.</span> <span class="php-string">&quot;` (
			`id` int(11) NOT NULL auto_increment,
			`post_id` int(11) NOT NULL,
			`image_name` varchar(255) NOT NULL,
			PRIMARY KEY  (`id`)
			);
			&quot;</span><span class="php-brackets">)</span>;
		<span class="php-brackets">}</span>

		<span class="php-comment">/*
		// Now I am going to delete all unnecessary thumb images by scanning the
		// whole directory
		*/</span>
		<span class="php-var">$sqlQuery</span> <span class="php-operator">=</span> <span class="php-string">&quot;SELECT image_name FROM &quot;</span> <span class="php-operator">.</span><span class="php-var">$wpdb</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>prefix <span class="php-operator">.</span> <span class="php-string">&quot;bag_thumb; &quot;</span>;
		<span class="php-var">$fileArray</span> <span class="php-operator">=</span> <span class="php-var">$wpdb</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>get_col<span class="php-brackets">(</span><span class="php-var">$sqlQuery</span><span class="php-brackets">)</span>;
		<span class="php-var">$fileArray</span><span class="php-brackets">[</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-string">'no_thumb.jpg'</span>;

		<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-var">$handle</span> <span class="php-operator">=</span> <span class="php-function">opendir</span><span class="php-brackets">(</span><span class="php-string">'../bag_thumb/'</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>

			<span class="php-comment">// This is the correct way to loop over the directory.
</span>
			<span class="php-keyword">while</span> <span class="php-brackets">(</span><span class="php-keyword">false</span> <span class="php-operator">!</span><span class="php-operator">=</span><span class="php-operator">=</span> <span class="php-brackets">(</span><span class="php-var">$file</span> <span class="php-operator">=</span> <span class="php-function">readdir</span><span class="php-brackets">(</span><span class="php-var">$handle</span><span class="php-brackets">)</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-function">is_file</span><span class="php-brackets">(</span><span class="php-string">'../bag_thumb/'</span> <span class="php-operator">.</span> <span class="php-var">$file</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-function">in_array</span><span class="php-brackets">(</span><span class="php-var">$file</span>, <span class="php-var">$fileArray</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
					<span class="php-brackets">{</span>
						<span class="php-function">unlink</span><span class="php-brackets">(</span><span class="php-string">'../bag_thumb/'</span> <span class="php-operator">.</span> <span class="php-var">$file</span><span class="php-brackets">)</span>;
					<span class="php-brackets">}</span>
				<span class="php-brackets">}</span>
			<span class="php-brackets">}</span>

			<span class="php-function">closedir</span><span class="php-brackets">(</span><span class="php-var">$handle</span><span class="php-brackets">)</span>;
		<span class="php-brackets">}</span>

	<span class="php-brackets">}</span>

	<span class="php-comment">// This function tells WP to add a new &quot;meta box&quot;
</span>
	<span class="php-function">function</span> add_bag_photo_box<span class="php-brackets">(</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>

		add_meta_box<span class="php-brackets">(</span>

			<span class="php-string">'bag_photo'</span>, <span class="php-comment">// id of the &lt;div&gt; we'll add
</span>
			<span class="php-string">'Add Bag Thumbnail Photo'</span>, <span class="php-comment">//title
</span>
			<span class="php-string">'add_bag_photo'</span>, <span class="php-comment">// callback function that will echo the box content
</span>
			<span class="php-string">'post'</span>, <span class="php-comment">// where to add the box: on &quot;post&quot;, &quot;page&quot;, or &quot;link&quot; page
</span>
			<span class="php-string">'normal'</span>,
			<span class="php-string">'high'</span> 

		<span class="php-brackets">)</span>;
	<span class="php-brackets">}</span>

	<span class="php-comment">// This function echoes the content of our meta box
</span>
	<span class="php-function">function</span> add_bag_photo<span class="php-brackets">(</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-keyword">echo</span>
			<span class="php-string">'&lt;label&gt; Select a thumbnail (150px by 100px) photo for this bag&lt;br /&gt;
			 &lt;input type=&quot;file&quot; name=&quot;bag_thumbnail_photo&quot; id=&quot;bag_thumbnail_photo&quot; /&gt;
			 &lt;/label&gt;
			 &lt;input name=&quot;bag_thumbnail_set&quot; type=&quot;hidden&quot; id=&quot;bag_thumbnail_set&quot; value=&quot;yes&quot; /&gt;
			'</span>;
	<span class="php-brackets">}</span>

	<span class="php-function">function</span> bag_thumbnail_plugin_save_postdata<span class="php-brackets">(</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-var">$fileArray</span> <span class="php-operator">=</span> <span class="php-keyword">array</span><span class="php-brackets">(</span><span class="php-brackets">)</span>;
		<span class="php-keyword">global</span> <span class="php-var">$wpdb</span>;

		<span class="php-var">$file</span> <span class="php-operator">=</span> <span class="php-var">$_FILES</span><span class="php-brackets">[</span><span class="php-string">'bag_thumbnail_photo'</span><span class="php-brackets">]</span>;
		<span class="php-var">$fileName</span> <span class="php-operator">=</span> <span class="php-var">$_FILES</span><span class="php-brackets">[</span><span class="php-string">'bag_thumbnail_photo'</span><span class="php-brackets">]</span><span class="php-brackets">[</span><span class="php-string">'name'</span><span class="php-brackets">]</span>;
		<span class="php-var">$basename</span> <span class="php-operator">=</span> <span class="php-string">''</span>;

		<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$fileName</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-keyword">if</span><span class="php-brackets">(</span>isAllowedExtension<span class="php-brackets">(</span><span class="php-var">$_FILES</span><span class="php-brackets">[</span><span class="php-string">'bag_thumbnail_photo'</span><span class="php-brackets">]</span><span class="php-brackets">[</span><span class="php-string">'name'</span><span class="php-brackets">]</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>

				<span class="php-var">$postID</span> <span class="php-operator">=</span> <span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'post_ID'</span><span class="php-brackets">]</span>;

				<span class="php-comment"># Do uploading here
</span>
				<span class="php-var">$basename</span> <span class="php-operator">=</span> <span class="php-function">basename</span><span class="php-brackets">(</span> <span class="php-var">$_FILES</span><span class="php-brackets">[</span><span class="php-string">'bag_thumbnail_photo'</span><span class="php-brackets">]</span><span class="php-brackets">[</span><span class="php-string">'name'</span><span class="php-brackets">]</span><span class="php-brackets">)</span>;
				<span class="php-var">$basename</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">' '</span>, <span class="php-string">'_'</span>, <span class="php-var">$basename</span><span class="php-brackets">)</span>;
				<span class="php-var">$basename</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'-'</span>, <span class="php-string">'_'</span>, <span class="php-var">$basename</span><span class="php-brackets">)</span>;
				<span class="php-var">$basename</span> <span class="php-operator">=</span> <span class="php-function">strtolower</span><span class="php-brackets">(</span><span class="php-var">$basename</span><span class="php-brackets">)</span>;
				<span class="php-var">$basename</span> <span class="php-operator">=</span> <span class="php-var">$_POST</span><span class="php-brackets">[</span><span class="php-string">'post_ID'</span><span class="php-brackets">]</span> <span class="php-operator">.</span> <span class="php-string">'_'</span> <span class="php-operator">.</span> <span class="php-var">$basename</span>;
				<span class="php-var">$target_path</span> <span class="php-operator">=</span> <span class="php-string">'../bag_thumb/'</span>;
				<span class="php-var">$target_path</span> <span class="php-operator">=</span> <span class="php-var">$target_path</span> <span class="php-operator">.</span> <span class="php-var">$basename</span>; 

				<span class="php-var">$sqlQuery</span> <span class="php-operator">=</span> <span class="php-string">&quot;DELETE FROM &quot;</span> <span class="php-operator">.</span> <span class="php-var">$wpdb</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>prefix <span class="php-operator">.</span> <span class="php-string">&quot;bag_thumb WHERE post_id=$postID;&quot;</span>;
				<span class="php-var">$wpdb</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>query<span class="php-brackets">(</span><span class="php-var">$sqlQuery</span><span class="php-brackets">)</span>;

				<span class="php-function">move_uploaded_file</span><span class="php-brackets">(</span><span class="php-var">$_FILES</span><span class="php-brackets">[</span><span class="php-string">'bag_thumbnail_photo'</span><span class="php-brackets">]</span><span class="php-brackets">[</span><span class="php-string">'tmp_name'</span><span class="php-brackets">]</span>, <span class="php-var">$target_path</span><span class="php-brackets">)</span>;

				<span class="php-comment">// adding record in the database
</span>
				<span class="php-var">$sqlQuery</span> <span class="php-operator">=</span> <span class="php-string">&quot;INSERT INTO &quot;</span> <span class="php-operator">.</span>
				<span class="php-var">$wpdb</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>prefix <span class="php-operator">.</span> <span class="php-string">&quot;bag_thumb(post_id, image_name)
				VALUES($postID, '$basename')&quot;</span>;
				<span class="php-var">$wpdb</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>query<span class="php-brackets">(</span><span class="php-var">$sqlQuery</span><span class="php-brackets">)</span>;
			<span class="php-brackets">}</span>

		<span class="php-brackets">}</span>

	<span class="php-brackets">}</span>

	<span class="php-function">function</span> isAllowedExtension<span class="php-brackets">(</span><span class="php-var">$fileName</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-var">$allowedExtensions</span> <span class="php-operator">=</span> <span class="php-keyword">array</span><span class="php-brackets">(</span><span class="php-string">&quot;png&quot;</span>, <span class="php-string">&quot;gif&quot;</span>, <span class="php-string">&quot;jpg&quot;</span>, <span class="php-string">'jpeg'</span><span class="php-brackets">)</span>;
		<span class="php-keyword">return</span> <span class="php-function">in_array</span><span class="php-brackets">(</span><span class="php-function">end</span><span class="php-brackets">(</span><span class="php-function">explode</span><span class="php-brackets">(</span><span class="php-string">&quot;.&quot;</span>, <span class="php-var">$fileName</span><span class="php-brackets">)</span><span class="php-brackets">)</span>, <span class="php-var">$allowedExtensions</span><span class="php-brackets">)</span>;
	<span class="php-brackets">}</span>

	<span class="php-comment">// This starts whenever the plugin is loaded
</span>
	add_action<span class="php-brackets">(</span><span class="php-string">&quot;plugins_loaded&quot;</span>, <span class="php-string">&quot;init_bag_review_thumb_widget&quot;</span><span class="php-brackets">)</span>;

	<span class="php-comment">// Hook things in, late enough so that add_meta_box() is defined
</span>
	<span class="php-keyword">if</span> <span class="php-brackets">(</span>is_admin<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-comment">/* Use the admin_menu action to define the custom boxes */</span>
		add_action<span class="php-brackets">(</span><span class="php-string">'admin_menu'</span>, <span class="php-string">'add_bag_photo_box'</span><span class="php-brackets">)</span>;
	<span class="php-brackets">}</span>

	<span class="php-comment">/* Use the save_post action to do something with the data entered */</span>
	add_action<span class="php-brackets">(</span><span class="php-string">'save_post'</span>, <span class="php-string">'bag_thumbnail_plugin_save_postdata'</span><span class="php-brackets">)</span>;

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>Please notice that I dynamically delete any unnecessary file using the PHP&#8217;s <strong>unlink()</strong> function.</p>
<p><span style="text-decoration: underline;"><strong>Step Three: get your image name from the database</strong></span></p>
<p>I have placed the following code in my <strong>functions.php</strong> file.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>

	<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-function">function_exists</span><span class="php-brackets">(</span><span class="php-string">'getBagThumbName'</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-function">function</span> getBagThumbName<span class="php-brackets">(</span><span class="php-var">$postID</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-keyword">global</span> <span class="php-var">$wpdb</span>;
			<span class="php-var">$sqlQuery</span> <span class="php-operator">=</span> <span class="php-string">'SELECT image_name FROM '</span> <span class="php-operator">.</span> <span class="php-var">$wpdb</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>prefix <span class="php-operator">.</span> <span class="php-string">'bag_thumb WHERE post_id='</span> <span class="php-operator">.</span> <span class="php-var">$postID</span> <span class="php-operator">.</span> <span class="php-string">';'</span>;
			<span class="php-var">$fileName</span> <span class="php-operator">=</span> <span class="php-var">$wpdb</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>get_var<span class="php-brackets">(</span><span class="php-var">$sqlQuery</span><span class="php-brackets">)</span>;
			<span class="php-var">$fileName</span> <span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$fileName</span><span class="php-brackets">)</span>;
			<span class="php-var">$fileURL</span> <span class="php-operator">=</span> get_option<span class="php-brackets">(</span><span class="php-string">'siteurl'</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">'/bag_thumb/'</span> <span class="php-operator">.</span> <span class="php-var">$fileName</span>;
			<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$fileName</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">return</span> <span class="php-var">$fileURL</span>;
			<span class="php-brackets">}</span>
			<span class="php-keyword">else</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">return</span> <span class="php-brackets">(</span>get_option<span class="php-brackets">(</span><span class="php-string">'siteurl'</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">'/bag_thumb/no_thumb.jpg'</span><span class="php-brackets">)</span>;
			<span class="php-brackets">}</span>
		<span class="php-brackets">}</span>
	<span class="php-brackets">}</span>

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p><span style="text-decoration: underline;"><strong>Step Four: Link with the index.php or single.php or wherever you want</strong></span></p>
<p>See how I placed the thumbnail image source in the code of <span style="text-decoration: underline;"><strong>index.php</strong></span> and <span style="text-decoration: underline;"><strong>single.php</strong></span> file.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
</pre>
<pre><span class="php"><span class="php-operator">&lt;</span>div id<span class="php-operator">=</span><span class="php-string">&quot;singlePostAdRight&quot;</span><span class="php-operator">&gt;</span>
		<span class="php-operator">&lt;</span>a href<span class="php-operator">=</span><span class="php-string">&quot;#postContentAnchor&quot;</span><span class="php-operator">&gt;</span><span class="php-operator">&lt;</span>img src<span class="php-operator">=</span><span class="php-string">&quot;&lt;?php
		global $post;
		echo getBagThumbName($post-&gt;ID); ?&gt;&quot;</span> <span class="php-keyword">class</span><span class="php-operator">=</span><span class="php-string">&quot;singlePostThumb&quot;</span> border<span class="php-operator">=</span><span class="php-string">&quot;0&quot;</span> <span class="php-operator">/</span><span class="php-operator">&gt;</span><span class="php-operator">&lt;</span><span class="php-operator">/</span>a<span class="php-operator">&gt;</span>
	<span class="php-operator">&lt;</span><span class="php-operator">/</span>div<span class="php-operator">&gt;</span></span></pre>
</div>
<p><span style="text-decoration: underline;"><strong>Step Five: Test</strong></span></p>
<p>Now you need to test and we are done!</p>
<p>You can also download my little plugin if you want from here:<br />
<a title="Wordpress File Upload Plugin" href="http://www.tanzilo.com/demo/code/bag-thumb/bag-thumb.zip" target="_blank">http://www.tanzilo.com/demo/code/bag-thumb/bag-thumb.zip</a></p>
<p>Thank you for reading.</p>
<p><map name='google_ad_map_70_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/70?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_70_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=70&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2009%2F01%2F15%2Fwordpress-adding-a-custom-option-box-and-developing-file-upload-plugin%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2009/01/15/wordpress-adding-a-custom-option-box-and-developing-file-upload-plugin/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>WordPress: display posts by category ID. Solution with code &amp; example.</title>
		<link>http://www.tanzilo.com/2009/01/06/wordpress-display-posts-by-category-id-solution-with-code-example/</link>
		<comments>http://www.tanzilo.com/2009/01/06/wordpress-display-posts-by-category-id-solution-with-code-example/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 19:26:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[by category]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[id]]></category>
		<category><![CDATA[posts]]></category>
		<category><![CDATA[show]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=68</guid>
		<description><![CDATA[Hello Guy! Often in many blogging sites, you will see two or three columns of the most important categories. Recently I had to do this for a blog. It was a little bit cumbersome and time consuming. So, I would like to share the solution so that you can kill the time waste trying yourself [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Guy!</p>
<p>Often in many blogging sites, you will see two or three columns of the most important categories. Recently I had to do this for a blog. It was a little bit cumbersome and time consuming. So, I would like to share the solution so that you can kill the time waste trying yourself in case you do not know how to do it. In this solution, I show 5 posts at maximum from my chosen three categories.</p>
<p>OK.<br />
Let us start and let me show how to do it.</p>
<p><span style="text-decoration: underline;"><strong>Step One: See the sample what would be the output</strong></span></p>
<p><a href="http://www.tanzilo.com/wp-content/uploads/2009/01/posts-by-category-id.jpg" target="_blank"><img class="alignleft size-medium wp-image-69" style="float:none;" title="posts-by-category-id" src="http://www.tanzilo.com/wp-content/uploads/2009/01/posts-by-category-id-300x146.jpg" alt="" width="300" height="146" /></a></p>
<p>In the above image, you will notice that the first category has enough posts, so it can fetch 5 (five) posts for us. But in second column and third column, there are only three posts because those categories do not have more than three posts. And what I want to say at this point is &#8211; although we will try to get 5 posts from each category, we will not get enough in case that category has less than 5 (five) posts and this is done automatically.</p>
<p><span style="text-decoration: underline;"><strong>Step Two: Adding custom function</strong></span></p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>

	<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-function">function_exists</span><span class="php-brackets">(</span><span class="php-string">'postListByCategory'</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-function">function</span> categoryNameByCategoryID<span class="php-brackets">(</span><span class="php-var">$categoryID</span> <span class="php-operator">=</span> <span class="php-number">0</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-keyword">global</span> <span class="php-var">$wpdb</span>;
			<span class="php-var">$sqlQuery</span> <span class="php-operator">=</span> <span class="php-string">'SELECT name FROM '</span> <span class="php-operator">.</span> <span class="php-var">$wpdb</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>prefix <span class="php-operator">.</span> <span class="php-string">&quot;terms WHERE term_id=$categoryID&quot;</span>;
			<span class="php-keyword">return</span> <span class="php-var">$wpdb</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>get_var<span class="php-brackets">(</span><span class="php-var">$sqlQuery</span><span class="php-brackets">)</span>;
		<span class="php-brackets">}</span>
	<span class="php-brackets">}</span>

	<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-function">function_exists</span><span class="php-brackets">(</span><span class="php-string">'postListByCategory'</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-function">function</span> postListByCategoryID<span class="php-brackets">(</span><span class="php-var">$categoryID</span> <span class="php-operator">=</span> <span class="php-number">0</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-var">$outputString</span> <span class="php-operator">=</span> <span class="php-string">''</span>;
			query_posts<span class="php-brackets">(</span><span class="php-string">'orderby=name&amp;order=asc&amp;cat='</span> <span class="php-operator">.</span> <span class="php-var">$categoryID</span> <span class="php-operator">.</span> <span class="php-string">'&amp;showposts=5'</span><span class="php-brackets">)</span>;
			<span class="php-var">$outputString</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&lt;ul&gt;'</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
			<span class="php-keyword">while</span> <span class="php-brackets">(</span>have_posts<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">:</span> the_post<span class="php-brackets">(</span><span class="php-brackets">)</span>;
				<span class="php-var">$permaLink</span> <span class="php-operator">=</span> get_permalink<span class="php-brackets">(</span><span class="php-brackets">)</span>;
				<span class="php-var">$permaLink</span> <span class="php-operator">=</span> <span class="php-function">trim</span><span class="php-brackets">(</span><span class="php-var">$permaLink</span><span class="php-brackets">)</span>;
				<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-operator">!</span><span class="php-keyword">empty</span><span class="php-brackets">(</span><span class="php-var">$permaLink</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-var">$outputString</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&lt;li&gt;'</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
					<span class="php-var">$outputString</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&lt;a href=&quot;'</span> <span class="php-operator">.</span> get_permalink<span class="php-brackets">(</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">'&quot;&gt;'</span> <span class="php-operator">.</span> get_the_title<span class="php-brackets">(</span><span class="php-var">$post</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>ID<span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">'&lt;/a&gt;&lt;br /&gt;'</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
					<span class="php-var">$outputString</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&lt;small&gt;'</span> <span class="php-operator">.</span> get_the_time<span class="php-brackets">(</span><span class="php-string">'D M jS Y'</span><span class="php-brackets">)</span> <span class="php-operator">.</span><span class="php-string">'&lt;/small&gt;'</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
					<span class="php-var">$outputString</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&lt;/li&gt;'</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
				<span class="php-brackets">}</span>
			<span class="php-keyword">endwhile</span>;
			<span class="php-var">$outputString</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&lt;/ul&gt;'</span> <span class="php-operator">.</span> <span class="php-function">chr</span><span class="php-brackets">(</span><span class="php-number">1</span><span class="php-number">0</span><span class="php-brackets">)</span>;
			<span class="php-keyword">return</span> <span class="php-var">$outputString</span>;
		<span class="php-brackets">}</span>
	<span class="php-brackets">}</span>

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>Now open the <strong>functions.php</strong> file inside your theme directory and insert these two functions. If there is none, create a <strong>functions.php</strong> file. And at this point, please remember that all the functions and coding in this file are automatically added during the code execution.</p>
<p>Note that the function names are self descriptive.</p>
<p><span style="text-decoration: underline;"><strong>Step Three: Embed code in your file(s)</strong></span></p>
<p>Now open your <strong>footer.php</strong> file or any other file and add this code. In 99% cases, you may need to customize this small piece of code. The first three lines are category IDs.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>

	<span class="php-var">$firstColumnCategoryID</span>  <span class="php-operator">=</span> <span class="php-number">1</span>;
	<span class="php-var">$secondColumnCategoryID</span> <span class="php-operator">=</span> <span class="php-number">3</span><span class="php-number">0</span>;
	<span class="php-var">$thirdColumnCategoryID</span>  <span class="php-operator">=</span> <span class="php-number">3</span><span class="php-number">1</span>;

<span class="php-script-tag">?&gt;<span class="html">
	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;bottomThreeColumns&quot;</span>&gt;</span>
		<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;bottomColumn&quot;</span>&gt;</span>
			<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;bottomColumnTop&quot;</span>&gt;</span><span class="html-special-char">&amp;nbsp;</span></span>&lt;?php</span> <span class="php-keyword">echo</span> categoryNameByCategoryID<span class="php-brackets">(</span><span class="php-var">$firstColumnCategoryID</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html"><span class="html-other-element">&lt;/div&gt;</span>
			</span>&lt;?php</span> <span class="php-keyword">echo</span> postListByCategoryID<span class="php-brackets">(</span><span class="php-var">$firstColumnCategoryID</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">
		<span class="html-other-element">&lt;/div&gt;</span>
		<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;bottomColumn&quot;</span>&gt;</span>
			<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;bottomColumnTop&quot;</span>&gt;</span><span class="html-special-char">&amp;nbsp;</span></span>&lt;?php</span> <span class="php-keyword">echo</span> categoryNameByCategoryID<span class="php-brackets">(</span><span class="php-var">$secondColumnCategoryID</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html"><span class="html-other-element">&lt;/div&gt;</span>
				</span>&lt;?php</span> <span class="php-keyword">echo</span> postListByCategoryID<span class="php-brackets">(</span><span class="php-var">$secondColumnCategoryID</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">
		<span class="html-other-element">&lt;/div&gt;</span>
		<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;bottomColumnThird&quot;</span>&gt;</span>
			<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;bottomColumnTop&quot;</span>&gt;</span><span class="html-special-char">&amp;nbsp;</span></span>&lt;?php</span> <span class="php-keyword">echo</span> categoryNameByCategoryID<span class="php-brackets">(</span><span class="php-var">$thirdColumnCategoryID</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html"><span class="html-other-element">&lt;/div&gt;</span>
			</span>&lt;?php</span> <span class="php-keyword">echo</span> postListByCategoryID<span class="php-brackets">(</span><span class="php-var">$thirdColumnCategoryID</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">
		<span class="html-other-element">&lt;/div&gt;</span>
	<span class="html-other-element">&lt;/div&gt;</span></span></span></span></pre>
</div>
<p><span style="text-decoration: underline;"><strong>Step Four: Link your CSS code</strong></span></p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="css">#<span class="css-property">bottomThreeColumns
{
	width<span class="css-selector">:</span><span class="css-value">940px</span></span>; <span class="css-property">min-height<span class="css-selector">:</span><span class="css-value">100px</span></span>; <span class="css-property">margin<span class="css-selector">:</span><span class="css-value">0 auto</span></span>; <span class="css-property">clear<span class="css-selector">:</span><span class="css-value">both</span></span>;
}
#<span class="css-property">bottomThreeColumns UL
{
	margin<span class="css-selector">:</span><span class="css-value">0px 0px 30px 0px</span></span>; <span class="css-property">padding<span class="css-selector">:</span><span class="css-value">0px</span></span>;
}
#<span class="css-property">bottomThreeColumns LI
{
	list-style<span class="css-selector">:</span><span class="css-value">none</span></span>; <span class="css-property">border-bottom<span class="css-selector">:</span><span class="css-value">#EEEEEE solid 1px</span></span>; <span class="css-property">margin<span class="css-selector">:</span><span class="css-value">7px 0px 0px 4px</span></span>;
}
#<span class="css-property">bottomThreeColumns LI A
{
	text-decoration<span class="css-selector">:</span><span class="css-value">none</span></span>; <span class="css-property">color<span class="css-selector">:</span><span class="css-value">#000000</span></span>;
}
#<span class="css-property">bottomThreeColumns LI A<span class="css-selector">:</span><span class="css-value">hover
{
	text-decoration:underline</span></span>;
}
#<span class="css-property">bottomThreeColumns SMALL
{
	font-style<span class="css-selector">:</span><span class="css-value">italic</span></span>; <span class="css-property">line-height<span class="css-selector">:</span><span class="css-value">25px</span></span>; <span class="css-property">padding<span class="css-selector">:</span><span class="css-value">0px 0px 0px 4px</span></span>;
}
#<span class="css-property">bottomColumn
{
	float<span class="css-selector">:</span><span class="css-value">left</span></span>; <span class="css-property">width<span class="css-selector">:</span><span class="css-value">300px</span></span>; <span class="css-property">margin<span class="css-selector">:</span><span class="css-value">20px 20px 0px 0px</span></span>;
}
#<span class="css-property">bottomColumnThird
{
	float<span class="css-selector">:</span><span class="css-value">left</span></span>; <span class="css-property">width<span class="css-selector">:</span><span class="css-value">300px</span></span>; <span class="css-property">margin<span class="css-selector">:</span><span class="css-value">20px 0px 0px 0px</span></span>;
}
#<span class="css-property">bottomColumnTop
{
	width<span class="css-selector">:</span><span class="css-value">300px</span></span>; <span class="css-property">height<span class="css-selector">:</span><span class="css-value">26px</span></span>; <span class="css-property">background<span class="css-selector">:</span><span class="css-value">#5FB8EB</span></span>; <span class="css-property">color<span class="css-selector">:</span><span class="css-value">#FFFFFF</span></span>;
	<span class="css-property">line-height<span class="css-selector">:</span><span class="css-value">25px</span></span>; <span class="css-property">font-weight<span class="css-selector">:</span><span class="css-value">bold</span></span>;
}</span></pre>
</div>
<p>I have put the above CSS code in my <strong>style.css</strong> file. In 99% cases, you may need to customize according to your requirements.</p>
<p><span style="text-decoration: underline;"><strong>Step Five: Test everything by opening the link</strong></span></p>
<p>Now test you code and we are done!</p>
<p>Thank you for reading.</p>
<p><map name='google_ad_map_68_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/68?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_68_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=68&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2009%2F01%2F06%2Fwordpress-display-posts-by-category-id-solution-with-code-example%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2009/01/06/wordpress-display-posts-by-category-id-solution-with-code-example/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>PHP: Serialization &amp; Unserialization explanation, code &amp; example</title>
		<link>http://www.tanzilo.com/2008/12/31/php-serialization-unserialization-explanation-code-example/</link>
		<comments>http://www.tanzilo.com/2008/12/31/php-serialization-unserialization-explanation-code-example/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 13:00:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[explanation]]></category>
		<category><![CDATA[Serialization]]></category>
		<category><![CDATA[Unserialization]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=62</guid>
		<description><![CDATA[Hello Folks! When I was new to PHP 5 Object Oriented Programming (OOP), the serialization and un-serialization issues were not clear to me and I used to get confused with them often. Nowadays I can play with them easily and I will try to share my knowledge with you so that you can kill your [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Folks!</p>
<p>When I was new to PHP 5 Object Oriented Programming (OOP), the serialization and un-serialization issues were not clear to me and I used to get confused with them often. Nowadays I can play with them easily and I will try to share my knowledge with you so that you can kill your confusion on these topics.</p>
<p>OK. Let us start!</p>
<p><span style="text-decoration: underline;"><strong>What is Serialization?</strong></span></p>
<p>This process makes a storable representation of a value that is useful for storing or passing PHP values around without losing their type and structure.</p>
<p><span style="text-decoration: underline;"><strong>Remember the &#8220;__sleep&#8221; function in case of Serialization</strong></span></p>
<p>Before starting your serialization process, PHP will execute the <strong>__sleep</strong> function automatically. This is a magic function or method.</p>
<p><span style="text-decoration: underline;"><strong>What is Unserialization?</strong></span></p>
<p>This process takes a single serialized variable and converts it back into a PHP value.</p>
<p><span style="text-decoration: underline;"><strong>Remember the &#8220;__wakeup&#8221; function in case of Unserialization</strong></span></p>
<p>Before starting your unserialization process, PHP will execute the <strong>__wakeup</strong> function automatically. This is a magic function or method.</p>
<p><span style="text-decoration: underline;"><strong>What can you Serialize and Unserialize?</strong></span></p>
<p>Many things as such</p>
<ol>
<li>Variables (Integer, Float, Real, String etc.)</li>
<li>Arrays</li>
<li>Objects etc.</li>
</ol>
<p><span style="text-decoration: underline;"><strong>What cannot you Serialize and Unserialize?</strong></span></p>
<p>Only one type</p>
<ol>
<li>Resource-type</li>
</ol>
<p><span style="text-decoration: underline;"><strong>A simple example of Serialization and Unserialization</strong></span></p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>

	<span class="php-keyword">require_once</span> <span class="php-string">&quot;class.serialize.php&quot;</span>;
	<span class="php-var">$myObject</span> <span class="php-operator">=</span> <span class="php-keyword">new</span> SerializationTest<span class="php-brackets">(</span><span class="php-brackets">)</span>;
	<span class="php-var">$myObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>counter <span class="php-operator">=</span> <span class="php-number">9</span><span class="php-number">9</span><span class="php-number">9</span>;
	<span class="php-var">$myObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>myName  <span class="php-operator">=</span> <span class="php-string">'Random Visitor'</span>;
	<span class="php-var">$myObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>myAge   <span class="php-operator">=</span> <span class="php-number">5</span><span class="php-number">9</span>;

	<span class="php-var">$myString</span> <span class="php-operator">=</span> <span class="php-string">'I am a simple line.'</span>;
	<span class="php-var">$myArray</span> <span class="php-operator">=</span> <span class="php-keyword">array</span><span class="php-brackets">(</span><span class="php-brackets">)</span>;
	<span class="php-var">$myArray</span><span class="php-brackets">[</span><span class="php-number">0</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-string">'One'</span>;
	<span class="php-var">$myArray</span><span class="php-brackets">[</span><span class="php-number">1</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-string">'Two'</span>;
	<span class="php-var">$myArray</span><span class="php-brackets">[</span><span class="php-number">2</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-string">'Three'</span>;

	<span class="php-keyword">echo</span> <span class="php-var">$myString</span> <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-function">var_dump</span><span class="php-brackets">(</span><span class="php-var">$myArray</span><span class="php-brackets">)</span>;
	<span class="php-keyword">echo</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-keyword">echo</span> <span class="php-string">'$myObject-&gt;counter: '</span> <span class="php-operator">.</span> <span class="php-var">$myObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>counter <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-keyword">echo</span> <span class="php-string">'$myObject-&gt;myName: '</span> <span class="php-operator">.</span> <span class="php-var">$myObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>myName <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-keyword">echo</span> <span class="php-string">'$myObject-&gt;myAge: '</span> <span class="php-operator">.</span> <span class="php-var">$myObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>myAge <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-function">var_dump</span><span class="php-brackets">(</span><span class="php-var">$myObject</span><span class="php-brackets">)</span>;

	<span class="php-var">$mySerializedString</span> <span class="php-operator">=</span> <span class="php-function">serialize</span><span class="php-brackets">(</span><span class="php-var">$myString</span><span class="php-brackets">)</span>;
	<span class="php-var">$mySerializedArray</span> <span class="php-operator">=</span> <span class="php-function">serialize</span><span class="php-brackets">(</span><span class="php-var">$myArray</span><span class="php-brackets">)</span>;
	<span class="php-var">$mySerializedObject</span> <span class="php-operator">=</span> <span class="php-function">serialize</span><span class="php-brackets">(</span><span class="php-var">$myObject</span><span class="php-brackets">)</span>;

	<span class="php-var">$myString</span> <span class="php-operator">=</span> <span class="php-string">'I have changed!'</span>;
	<span class="php-var">$myArray</span><span class="php-brackets">[</span><span class="php-number">0</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-string">'New 1'</span>;
	<span class="php-var">$myArray</span><span class="php-brackets">[</span><span class="php-number">1</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-string">'New 2'</span>;
	<span class="php-var">$myArray</span><span class="php-brackets">[</span><span class="php-number">2</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-string">'New 3'</span>;

	<span class="php-keyword">echo</span> <span class="php-string">'&lt;br /&gt;&lt;br /&gt;'</span>;
	<span class="php-keyword">echo</span> <span class="php-var">$myString</span> <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-function">var_dump</span><span class="php-brackets">(</span><span class="php-var">$myArray</span><span class="php-brackets">)</span>;
	<span class="php-keyword">echo</span> <span class="php-string">'&lt;br /&gt;'</span>;

	<span class="php-var">$myUnserializedString</span> <span class="php-operator">=</span> <span class="php-function">unserialize</span><span class="php-brackets">(</span><span class="php-var">$mySerializedString</span><span class="php-brackets">)</span>;
	<span class="php-var">$myUnserializedArray</span> <span class="php-operator">=</span> <span class="php-function">unserialize</span><span class="php-brackets">(</span><span class="php-var">$mySerializedArray</span><span class="php-brackets">)</span>;
	<span class="php-var">$myUnserializedObject</span> <span class="php-operator">=</span> <span class="php-function">unserialize</span><span class="php-brackets">(</span><span class="php-var">$mySerializedObject</span><span class="php-brackets">)</span>;

	<span class="php-keyword">echo</span> <span class="php-string">'&lt;br /&gt;&lt;br /&gt;'</span>;
	<span class="php-keyword">echo</span> <span class="php-var">$myUnserializedString</span> <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-function">var_dump</span><span class="php-brackets">(</span><span class="php-var">$myUnserializedArray</span><span class="php-brackets">)</span>;
	<span class="php-keyword">echo</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-keyword">echo</span> <span class="php-string">'$myUnserializedObject-&gt;counter: '</span> <span class="php-operator">.</span> <span class="php-var">$myUnserializedObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>counter <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-keyword">echo</span> <span class="php-string">'$myUnserializedObject-&gt;myName: '</span> <span class="php-operator">.</span> <span class="php-var">$myUnserializedObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>myName <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-keyword">echo</span> <span class="php-string">'$myUnserializedObject-&gt;myAge: '</span> <span class="php-operator">.</span> <span class="php-var">$myUnserializedObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>myAge <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-function">var_dump</span><span class="php-brackets">(</span><span class="php-var">$myUnserializedObject</span><span class="php-brackets">)</span>;

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>And here is the related class:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>

	<span class="php-keyword">class</span> SerializationTest
	<span class="php-brackets">{</span>
		<span class="php-keyword">public</span> <span class="php-var">$counter</span>;
		<span class="php-keyword">public</span> <span class="php-var">$myName</span>;
		<span class="php-keyword">public</span> <span class="php-var">$myAge</span>;
		<span class="php-function">function</span> __construct<span class="php-brackets">(</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>counter <span class="php-operator">=</span> <span class="php-number">1</span><span class="php-number">0</span><span class="php-number">0</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>myName  <span class="php-operator">=</span> <span class="php-string">'Tanzilo Insido'</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>myAge   <span class="php-operator">=</span> <span class="php-number">2</span><span class="php-number">8</span>;
		<span class="php-brackets">}</span>

		<span class="php-function">function</span> __sleep<span class="php-brackets">(</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-keyword">echo</span> <span class="php-string">&quot;&lt;h3&gt;__sleep()&lt;/h3&gt;&quot;</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>counter <span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>counter <span class="php-operator">+</span> <span class="php-number">1</span>;
			<span class="php-keyword">echo</span> <span class="php-string">'Serialization Process Started!'</span> <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
			<span class="php-keyword">echo</span> <span class="php-string">'$this-&gt;counter: '</span> <span class="php-operator">.</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>counter <span class="php-operator">.</span>  <span class="php-string">'&lt;br /&gt;'</span>;
			<span class="php-keyword">return</span> <span class="php-keyword">array</span><span class="php-brackets">(</span>myString<span class="php-brackets">)</span>;
		<span class="php-brackets">}</span>

		<span class="php-function">function</span> __wakeup<span class="php-brackets">(</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-keyword">echo</span> <span class="php-string">&quot;&lt;h3&gt;__wakeup()&lt;/h3&gt;&quot;</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>counter <span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>counter <span class="php-operator">-</span> <span class="php-number">1</span>;
			<span class="php-keyword">echo</span> <span class="php-string">'UnSerialization Process Started!'</span> <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
			<span class="php-keyword">echo</span> <span class="php-string">'$this-&gt;counter: '</span> <span class="php-operator">.</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>counter <span class="php-operator">.</span>  <span class="php-string">'&lt;br /&gt;'</span>;
		<span class="php-brackets">}</span>

	<span class="php-brackets">}</span>

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p><span style="text-decoration: underline;"><strong>Explanation of the example</strong></span></p>
<p>If you notice the A to Z of the above code, you will find that we have a <strong>$myString</strong> variable, <strong>$myArray</strong> array and <strong>$myObject</strong> object. First of all, we have set values to them and then printed them all. They all perform as expected. Then we change all the values. Next when we serialize and unserialize the values, our original dara structure returns! And that is what we wanted.</p>
<p>Here is the result of the above code:</p>
<p><a href="http://www.tanzilo.com/wp-content/uploads/2008/12/serialize_1.jpg"><img class="alignleft size-full wp-image-65" title="serialize_1" src="http://www.tanzilo.com/wp-content/uploads/2008/12/serialize_1.jpg" alt="" width="500" height="337" style="float:none;" /></a></p>
<p><span style="text-decoration: underline;"><strong>An interesting thing to note:</strong></span><br />
I would like to draw your attention to the fact that using <strong>__sleep()</strong> method, you can change the values of your declared and initialized variables. But you cannot change them by using <strong>__wakeup()</strong> function. For example, see the following code:</p>
<p>Now we serialize 3 (three)  times and unserialize 2 (two) times.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>

	<span class="php-keyword">require_once</span> <span class="php-string">&quot;class.serialize.php&quot;</span>;
	<span class="php-var">$myObject</span> <span class="php-operator">=</span> <span class="php-keyword">new</span> SerializationTest<span class="php-brackets">(</span><span class="php-brackets">)</span>;

	<span class="php-keyword">echo</span> <span class="php-string">'&lt;h3&gt;Start Value:&lt;/h3&gt;'</span>;
	<span class="php-keyword">echo</span> <span class="php-string">'$this-&gt;counter: '</span> <span class="php-operator">.</span> <span class="php-var">$myObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>counter <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
	<span class="php-keyword">echo</span> <span class="php-string">'$this-&gt;myString: '</span> <span class="php-operator">.</span> <span class="php-var">$myObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>myString;

	<span class="php-var">$serializeData_1</span> <span class="php-operator">=</span> <span class="php-function">serialize</span><span class="php-brackets">(</span><span class="php-var">$myObject</span><span class="php-brackets">)</span>;
	<span class="php-var">$serializeData_2</span> <span class="php-operator">=</span> <span class="php-function">serialize</span><span class="php-brackets">(</span><span class="php-var">$myObject</span><span class="php-brackets">)</span>;
	<span class="php-var">$serializeData_3</span> <span class="php-operator">=</span> <span class="php-function">serialize</span><span class="php-brackets">(</span><span class="php-var">$myObject</span><span class="php-brackets">)</span>;

	<span class="php-var">$unSerializeData_1</span> <span class="php-operator">=</span> <span class="php-function">unserialize</span><span class="php-brackets">(</span><span class="php-var">$serializeData_1</span><span class="php-brackets">)</span>;
	<span class="php-var">$unSerializeData_2</span> <span class="php-operator">=</span> <span class="php-function">unserialize</span><span class="php-brackets">(</span><span class="php-var">$serializeData_2</span><span class="php-brackets">)</span>;

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>And here is the result if we serialize 3 (three)  times and unserialize 2 (two) times.</p>
<p><a href="http://www.tanzilo.com/wp-content/uploads/2008/12/serialize_2.jpg"><img class="alignleft size-full wp-image-66" title="serialize_2" src="http://www.tanzilo.com/wp-content/uploads/2008/12/serialize_2.jpg" alt="" width="236" height="591" style="float:none;" /></a></p>
<p>Although we initialized <strong>$this-&gt;counter</strong> variable in the <strong>__construct()</strong> function, it is not used or has no effect in <strong>__wakeup()</strong> function. But it works properly in <strong>__sleep()</strong> or <strong>serialize()</strong> process. But what is the reason? The explanation is simple. The <strong>__wakeup()</strong> is part of the process when your data is retrieved from memory. Another thing is &#8211; did you notice the array return in the <strong>__sleep()</strong> function? Without returning this, the process often does not work. So, please remember to keep in your code.</p>
<p><span style="text-decoration: underline;">You can download these small pieces of code files from here:</span><br />
<a title="PHP Serialize and Unserialize" href="http://www.tanzilo.com/demo/code/serialize/serialize.zip" target="_blank">http://www.tanzilo.com/demo/code/serialize/serialize.zip</a></p>
<p>Thank you for reading.</p>
<p><map name='google_ad_map_62_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/62?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_62_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=62&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2008%2F12%2F31%2Fphp-serialization-unserialization-explanation-code-example%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2008/12/31/php-serialization-unserialization-explanation-code-example/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>PHP &amp; MySQL: Creating a website in your local language smoothly</title>
		<link>http://www.tanzilo.com/2008/12/29/php-mysql-creating-a-website-in-your-local-language-smoothly/</link>
		<comments>http://www.tanzilo.com/2008/12/29/php-mysql-creating-a-website-in-your-local-language-smoothly/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 12:04:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Afrikaans]]></category>
		<category><![CDATA[Albanian]]></category>
		<category><![CDATA[Amharic]]></category>
		<category><![CDATA[Arabic]]></category>
		<category><![CDATA[Armenian]]></category>
		<category><![CDATA[Assamese]]></category>
		<category><![CDATA[Aymara]]></category>
		<category><![CDATA[Azeri]]></category>
		<category><![CDATA[Belarusian]]></category>
		<category><![CDATA[Bengali]]></category>
		<category><![CDATA[Bislama]]></category>
		<category><![CDATA[Bosnian]]></category>
		<category><![CDATA[Bulgarian]]></category>
		<category><![CDATA[Burmese]]></category>
		<category><![CDATA[Catalan]]></category>
		<category><![CDATA[Chinese]]></category>
		<category><![CDATA[Creating]]></category>
		<category><![CDATA[Croatian]]></category>
		<category><![CDATA[Czech]]></category>
		<category><![CDATA[Danish]]></category>
		<category><![CDATA[Dari]]></category>
		<category><![CDATA[Develop]]></category>
		<category><![CDATA[Dhivehi]]></category>
		<category><![CDATA[Dutch]]></category>
		<category><![CDATA[Dzongkha]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Esperanto]]></category>
		<category><![CDATA[Estonian]]></category>
		<category><![CDATA[Fijian]]></category>
		<category><![CDATA[Filipino]]></category>
		<category><![CDATA[Finnish]]></category>
		<category><![CDATA[French]]></category>
		<category><![CDATA[Frisian]]></category>
		<category><![CDATA[Gagauz]]></category>
		<category><![CDATA[Georgian]]></category>
		<category><![CDATA[German]]></category>
		<category><![CDATA[Greek]]></category>
		<category><![CDATA[Guaraní]]></category>
		<category><![CDATA[Gujarati]]></category>
		<category><![CDATA[Haitian Creole]]></category>
		<category><![CDATA[Hebrew]]></category>
		<category><![CDATA[Hindi]]></category>
		<category><![CDATA[Hiri Motu]]></category>
		<category><![CDATA[Hungarian]]></category>
		<category><![CDATA[Icelandic]]></category>
		<category><![CDATA[Indonesian]]></category>
		<category><![CDATA[Italian]]></category>
		<category><![CDATA[Japanese]]></category>
		<category><![CDATA[Kannada]]></category>
		<category><![CDATA[Kashmiri]]></category>
		<category><![CDATA[Kazakh]]></category>
		<category><![CDATA[Khmer]]></category>
		<category><![CDATA[Korean]]></category>
		<category><![CDATA[Kurdish]]></category>
		<category><![CDATA[Kyrgyz]]></category>
		<category><![CDATA[Lao]]></category>
		<category><![CDATA[Latvian]]></category>
		<category><![CDATA[Lithuanian]]></category>
		<category><![CDATA[local language]]></category>
		<category><![CDATA[Luxembourgish]]></category>
		<category><![CDATA[Macedonian]]></category>
		<category><![CDATA[Malagasy]]></category>
		<category><![CDATA[Malay]]></category>
		<category><![CDATA[Malayalam]]></category>
		<category><![CDATA[Maltese]]></category>
		<category><![CDATA[Mandarin]]></category>
		<category><![CDATA[Māori]]></category>
		<category><![CDATA[Marathi]]></category>
		<category><![CDATA[Mayan]]></category>
		<category><![CDATA[Moldovan]]></category>
		<category><![CDATA[Mongolian]]></category>
		<category><![CDATA[Montenegrin]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Náhuatl]]></category>
		<category><![CDATA[Ndebele]]></category>
		<category><![CDATA[Nepali]]></category>
		<category><![CDATA[New Zealand Sign Language]]></category>
		<category><![CDATA[Northern Sotho]]></category>
		<category><![CDATA[Norwegian]]></category>
		<category><![CDATA[Oriya]]></category>
		<category><![CDATA[Papiamento]]></category>
		<category><![CDATA[Pashto]]></category>
		<category><![CDATA[Persian]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Polish]]></category>
		<category><![CDATA[Portuguese]]></category>
		<category><![CDATA[Punjabi]]></category>
		<category><![CDATA[Quechua]]></category>
		<category><![CDATA[Rhaeto-Romansh]]></category>
		<category><![CDATA[Romanian]]></category>
		<category><![CDATA[Russian]]></category>
		<category><![CDATA[Sanskrit]]></category>
		<category><![CDATA[Serbian]]></category>
		<category><![CDATA[Shona]]></category>
		<category><![CDATA[Sindhi]]></category>
		<category><![CDATA[Sinhala]]></category>
		<category><![CDATA[Slovak]]></category>
		<category><![CDATA[Slovene]]></category>
		<category><![CDATA[Somali]]></category>
		<category><![CDATA[Sotho]]></category>
		<category><![CDATA[Spanish]]></category>
		<category><![CDATA[Swahili]]></category>
		<category><![CDATA[Swati]]></category>
		<category><![CDATA[Swedish]]></category>
		<category><![CDATA[Tagalog]]></category>
		<category><![CDATA[Tajik]]></category>
		<category><![CDATA[Tamil]]></category>
		<category><![CDATA[Telugu]]></category>
		<category><![CDATA[Tetum]]></category>
		<category><![CDATA[Thai]]></category>
		<category><![CDATA[Tok Pisin]]></category>
		<category><![CDATA[Tsonga]]></category>
		<category><![CDATA[Tswana]]></category>
		<category><![CDATA[Turkish]]></category>
		<category><![CDATA[Turkmen]]></category>
		<category><![CDATA[Ukrainian]]></category>
		<category><![CDATA[Urdu]]></category>
		<category><![CDATA[Uzbek]]></category>
		<category><![CDATA[Venda]]></category>
		<category><![CDATA[Vietnamese]]></category>
		<category><![CDATA[website]]></category>
		<category><![CDATA[Welsh]]></category>
		<category><![CDATA[Xhosa]]></category>
		<category><![CDATA[Yiddish]]></category>
		<category><![CDATA[Zulu]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=63</guid>
		<description><![CDATA[Hello Developer, You know English is the international language and accepted as international communication. So, most of the websites have been developed in English. But in many other times, a developer needs to work with local languages where they are developing a website in PHP. If you develop in local language, you need to know [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Developer,</p>
<p>You know English is the international language and accepted as international communication. So, most of the websites have been developed in English. But in many other times, a developer needs to work with local languages where they are developing a website in PHP. If you develop in local language, you need to know a small trick and that will show your content properly in all browsers smoothly.</p>
<p>So, what is the technique?</p>
<p>Well. Let me explain step by step.</p>
<p><span style="text-decoration: underline;"><strong>Step One: An observation</strong></span><br />
I will show you the source code of two Bengali newspaper. In this newspaper: <a title="Prothom Alo" href="http://www.prothom-alo.com/" target="_blank">http://www.prothom-alo.com</a>, the fonts and text comes properly in all browsers. But in this newspaper: <a title="Ittefaq" href="http://www.ittefaq.com" target="_blank">http://www.ittefaq.com</a>, it can show text and fonts properly only in Internet Explorer.</p>
<p>Now the matter is we must make sure our content will be displayed properly in any browser. Right?</p>
<p>OK. So what is the difference between the two websites I just gave example?</p>
<p>If you take a look at the source code of the first website&#8217;s content, you will find it is like this:<span style="text-decoration: underline;">&amp;<span class="entity">#2488;</span>&amp;<span class="entity">#2691;</span>&amp;<span class="entity">#2474;</span>&amp;<span class="entity">#2494;</span>&amp;<span class="entity">#2470;</span>&amp;<span class="entity">#2453;</span></span></p>
<p>This is another website that had been developed as smooth site in the same technique: <a title="bdnews 24" href="http://www.bdnews24.com/bangla" target="_blank">http://www.bdnews24.com/bangla</a>. If you check its code, you will see that it uses same type of code for its text.</p>
<p>So, what are these <span style="text-decoration: underline;">&amp;<span class="entity">#2474;</span>&amp;<span class="entity">#2494;</span>&amp;<span class="entity">#2470;</span>&amp;<span class="entity">#2453;</span>&amp;<span class="entity">#2496;</span>&amp;</span><span class="entity"><span style="text-decoration: underline;">#2527;</span> things? It is very interesting that these are universal representation of local language in HTML entities. For every character of any local language, there is a unique and fixed symbol defined such as </span><span style="text-decoration: underline;">&amp;<span class="entity">#2474;</span></span><span class="entity"> in HTML entities</span><span class="entity">. When you bring this kind of text in your browser source code, the site content looks smooth without any break and fonts displays properly.</span></p>
<p>Now if you open the source code of <a title="Ittefaq" href="http://www.ittefaq.com" target="_blank">http://www.ittefaq.com</a>, you will see something like <span style="text-decoration: underline;">AvR beg RvZxq msm` wbe©vP‡b jovB n‡e †RvU-gnv‡Rv‡Ui g‡a¨</span>. The matter is they are also showing Bengali news content, but in a different way that is not useful in cross-broswer platform. This is often totally recognized by only Internet Explorer and often partially recognized by other browsers.</p>
<p><span style="text-decoration: underline;"><strong>Step Two: Storing your local language content in the database</strong></span><br />
You see I have some content in my local language (Bangla) in the database.</p>
<p><a href="http://www.tanzilo.com/wp-content/uploads/2008/12/bangla_news_content.jpg"><img class="alignleft size-full wp-image-64" style="float:none;" title="bangla_news_content" src="http://www.tanzilo.com/wp-content/uploads/2008/12/bangla_news_content.jpg" alt="" width="500" height="174" /></a></p>
<p><span style="text-decoration: underline;"><strong>Step Three: Converting your local language text in Universal code</strong></span><br />
Well. This is extremely easy.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>

	<span class="php-keyword">class</span> UnicodeHandler
	<span class="php-brackets">{</span>
		<span class="php-keyword">var</span> <span class="php-var">$dbLink</span>;
		<span class="php-keyword">var</span> <span class="php-var">$sqlQuery</span>;
		<span class="php-keyword">var</span> <span class="php-var">$dbResult</span>;
		<span class="php-keyword">var</span> <span class="php-var">$dbRow</span>;
		<span class="php-keyword">var</span> <span class="php-var">$salary</span>;
		<span class="php-keyword">var</span> <span class="php-var">$bonus</span>;

		<span class="php-comment">/* Use this constructor in case your PHP version is 4. */</span>
<span class="php-comment">/*
		function UnicodeHandler()
		{
			$this-&gt;dbLink = '';
			$this-&gt;sqlQuery = '';
			$this-&gt;dbResult = '';
			$this-&gt;dbRow = '';
			$this-&gt;mySalary = 0;
			$this-&gt;myBonus = 0;

			$this-&gt;dbLink = mysql_connect('localhost', 'root', '');
			mysql_query(&quot;SET character_set_results=utf8&quot;, $this-&gt;dbLink);
			mb_language('uni');
			mb_internal_encoding('UTF-8');

			mysql_select_db('test', $this-&gt;dbLink);
			mysql_query(&quot;set names 'utf8'&quot;,$this-&gt;dbLink);
		}
*/</span>

		<span class="php-comment">/* Use this constructor in case your PHP version is 5 or 5+. */</span>
		<span class="php-comment">/* I assume you are using PHP 5 or 5+. */</span>
		<span class="php-function">function</span> __construct<span class="php-brackets">(</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>sqlQuery <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbResult <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbRow <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>mySalary <span class="php-operator">=</span> <span class="php-number">0</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>myBonus <span class="php-operator">=</span> <span class="php-number">0</span>;

			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink <span class="php-operator">=</span> <span class="php-function">mysql_connect</span><span class="php-brackets">(</span><span class="php-string">'localhost'</span>, <span class="php-string">'root'</span>, <span class="php-string">''</span><span class="php-brackets">)</span>;
			<span class="php-function">mysql_query</span><span class="php-brackets">(</span><span class="php-string">&quot;SET character_set_results=utf8&quot;</span>, <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink<span class="php-brackets">)</span>;
			<span class="php-function">mb_language</span><span class="php-brackets">(</span><span class="php-string">'uni'</span><span class="php-brackets">)</span>;
			<span class="php-function">mb_internal_encoding</span><span class="php-brackets">(</span><span class="php-string">'UTF-8'</span><span class="php-brackets">)</span>;

			<span class="php-function">mysql_select_db</span><span class="php-brackets">(</span><span class="php-string">'test'</span>, <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink<span class="php-brackets">)</span>;
			<span class="php-function">mysql_query</span><span class="php-brackets">(</span><span class="php-string">&quot;set names 'utf8'&quot;</span>,<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink<span class="php-brackets">)</span>;
		<span class="php-brackets">}</span>

		<span class="php-function">function</span> displayLocalContent<span class="php-brackets">(</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-function">mysql_query</span><span class="php-brackets">(</span><span class="php-string">&quot;SET character_set_results=utf8&quot;</span>, <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink<span class="php-brackets">)</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>sqlQuery <span class="php-operator">=</span> <span class="php-string">&quot;SELECT * FROM unitext &quot;</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbResult <span class="php-operator">=</span> <span class="php-function">mysql_query</span><span class="php-brackets">(</span><span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>sqlQuery, <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink<span class="php-brackets">)</span>;
			<span class="php-keyword">while</span><span class="php-brackets">(</span><span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbRow <span class="php-operator">=</span> <span class="php-function">mysql_fetch_object</span><span class="php-brackets">(</span><span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbResult<span class="php-brackets">)</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">echo</span> <span class="php-string">'News: '</span> <span class="php-operator">.</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>convertToLocalHtml<span class="php-brackets">(</span><span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbRow<span class="php-operator">-</span><span class="php-operator">&gt;</span>news<span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
			<span class="php-brackets">}</span>

		<span class="php-brackets">}</span>

		<span class="php-function">function</span> convertToLocalHtml<span class="php-brackets">(</span><span class="php-var">$localHtmlEquivalent</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>

			<span class="php-var">$localHtmlEquivalent</span> <span class="php-operator">=</span> <span class="php-function">mb_convert_encoding</span><span class="php-brackets">(</span><span class="php-var">$localHtmlEquivalent</span>,<span class="php-string">&quot;HTML-ENTITIES&quot;</span>,<span class="php-string">&quot;UTF-8&quot;</span><span class="php-brackets">)</span>;
			<span class="php-keyword">return</span> <span class="php-var">$localHtmlEquivalent</span>;
		<span class="php-brackets">}</span>
	<span class="php-brackets">}</span>

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>The <span style="text-decoration: underline;">displayLocalContent()</span> function is going to display the news and <span style="text-decoration: underline;">convertToLocalHtml()</span> function converts my utf-8 content to HTML entities.</p>
<p>And here in <strong>index.php</strong> I am executing my <span style="text-decoration: underline;">displayLocalContent()</span> function.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-operator">&lt;</span><span class="php-operator">!</span>DOCTYPE html PUBLIC <span class="php-string">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span class="php-string">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span class="php-operator">&gt;</span>
<span class="php-operator">&lt;</span>html xmlns<span class="php-operator">=</span><span class="php-string">&quot;http://www.w3.org/1999/xhtml&quot;</span><span class="php-operator">&gt;</span>
<span class="php-operator">&lt;</span>head<span class="php-operator">&gt;</span>
<span class="php-operator">&lt;</span>meta http<span class="php-operator">-</span>equiv<span class="php-operator">=</span><span class="php-string">&quot;Content-Type&quot;</span> content<span class="php-operator">=</span><span class="php-string">&quot;text/html; charset=utf-8&quot;</span> <span class="php-operator">/</span><span class="php-operator">&gt;</span>
<span class="php-operator">&lt;</span>title<span class="php-operator">&gt;</span>Displaying Your Local Language<span class="php-operator">&lt;</span><span class="php-operator">/</span>title<span class="php-operator">&gt;</span>
<span class="php-operator">&lt;</span><span class="php-operator">/</span>head<span class="php-operator">&gt;</span>

<span class="php-operator">&lt;</span>body<span class="php-operator">&gt;</span>
<span class="php-script-tag">&lt;?php</span>

	<span class="php-keyword">include_once</span> <span class="php-string">'class.unicode.php'</span>;
	<span class="php-var">$unicodeObject</span> <span class="php-operator">=</span> <span class="php-keyword">new</span> UnicodeHandler<span class="php-brackets">(</span><span class="php-brackets">)</span>;
	<span class="php-var">$unicodeObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>displayLocalContent<span class="php-brackets">(</span><span class="php-brackets">)</span>;

<span class="php-script-tag">?&gt;<span class="html">
<span class="html-other-element">&lt;/body&gt;</span>
<span class="html-other-element">&lt;/html&gt;</span></span></span></span></pre>
</div>
<p>As a result, the output is now as <span style="text-decoration: underline;">ঢাকা, ডিসে</span> etc.</p>
<p><span style="text-decoration: underline;"><strong>Step Four: You need to check my other posting for SELECT, INSERT &amp; UPDATE your local language.</strong></span><br />
Here goes my other article so that you can perform all required operations for storing and displaying information in browser smoothly:<br />
<a title="Php mysql unicode solution to chinese russian or any language" href="http://www.tanzilo.com/2008/10/13/php-mysql-unicode-solution-to-chinese-russian-or-any-language/" target="_blank">http://www.tanzilo.com/2008/10/13/php-mysql-unicode-solution-to-chinese-russian-or-any-language/</a></p>
<p><span style="text-decoration: underline;"><strong>An alternative way</strong></span><br />
I have an alternative way in my mind and that is when you store the data in the database, you can first convert them to universal code such as <span style="text-decoration: underline;">&amp;<span class="entity">#2453;</span>&amp;<span class="entity">#2496;</span>&amp;</span><span class="entity"><span style="text-decoration: underline;">#2527;</span></span>and then directly show your text.</p>
<p><strong>This article will cover any language such as</strong> Afrikaans, Albanian, Amharic, Arabic, Armenian, Assamese, Aymara, Azeri, Belarusian, Bengali, Bislama, Bosnian, Bulgarian, Burmese, Catalan, Chinese, Mandarin,Croatian, Czech, Danish, Dari, Dhivehi, Dutch, Dzongkha, English, Esperanto, Estonian, Fijian, Filipino, Finnish, French, Frisian,  Gagauz, Georgian, German, Greek, Guaraní, Gujarati, Haitian Creole, Hebrew, Hindi, Hiri Motu, Hungarian, Icelandic, Indonesian, Italian, Japanese, Kannada, Kashmiri, Kazakh, Khmer, Korean, Kurdish, Kyrgyz, Lao, Latvian, Lithuanian, Luxembourgish, Macedonian, Malagasy, Malay, Malayalam, Maltese, Māori, Marathi, Mayan, Moldovan, Mongolian, Montenegrin,Náhuatl, Ndebele, Nepali, New Zealand Sign Language, Northern Sotho, Norwegian, Oriya, Papiamento, Pashto, Persian, Polish, Portuguese, Punjabi, Quechua, Romanian, Rhaeto-Romansh, Russian, Sanskrit, Serbian, Shona, Sindhi, Sinhala, Slovak, Slovene, Somali, Sotho, Spanish, Swahili, Swati, Swedish, Tagalog, Tajik, Tamil, Telugu, Tetum, Thai, Tok Pisin, Tsonga, Tswana, Turkish, Turkmen, Ukrainian, Urdu, Uzbek, Venda, Vietnamese, Welsh, Xhosa, Yiddish, Zulu etc.</p>
<p>You can also download this small piece of code from here:<br />
<a title="convert to unicode" href="http://www.tanzilo.com/demo/code/convert_to_unicode/convert_to_unicode.zip" target="_blank">http://www.tanzilo.com/demo/code/convert_to_unicode/convert_to_unicode.zip</a></p>
<p>Thank you for reading.</p>
<p><map name='google_ad_map_63_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/63?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_63_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=63&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2008%2F12%2F29%2Fphp-mysql-creating-a-website-in-your-local-language-smoothly%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2008/12/29/php-mysql-creating-a-website-in-your-local-language-smoothly/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>PHP &amp; MySQL: Unicode number add, subtract etc for any language</title>
		<link>http://www.tanzilo.com/2008/12/23/php-mysql-unicode-number-add-subtract-etc-for-any-language/</link>
		<comments>http://www.tanzilo.com/2008/12/23/php-mysql-unicode-number-add-subtract-etc-for-any-language/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 18:22:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[any language]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[divide]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[multiply]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[subtract]]></category>
		<category><![CDATA[Unicode]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=60</guid>
		<description><![CDATA[Hello Coders! Recently a visitor from my country asked me how he can add Unicode numbers stored in MySQL database.  I was thinking that it is really a good question. Because you may store any number in any local language to your database and later you may try to add or delete them. For example, [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Coders!</p>
<p>Recently a visitor from my country asked me how he can add Unicode numbers stored in MySQL database.  I was thinking that it is really a good question. Because you may store any number in any local language to your database and later you may try to add or delete them.</p>
<p>For example, in Bangla language an employee&#8217;s salary can be <span style="text-decoration: underline;"><strong><span class="Apple-style-span" style="border-collapse: separate; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-family: 'Times New Roman'; color: #000000;">২৪</span><span class="Apple-style-span" style="border-collapse: separate; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-family: 'Times New Roman'; color: #000000;">১৮৬</span></strong></span> (which is 24186 in English) bucks and the coder may want to store it in a table under <span style="text-decoration: underline;">salary</span> field. Another field can be bonus and it can be <span style="text-decoration: underline;"><strong><span class="Apple-style-span" style="border-collapse: separate; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-family: 'Times New Roman'; color: #000000;">২০০</span></strong></span><span style="text-decoration: underline;"><strong><span class="Apple-style-span" style="border-collapse: separate; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-family: 'Times New Roman'; color: #000000;">০</span></strong></span> (2000 in English). Now the coder may want to add them up anytime required. You know adding 24186 and 2000 is easy. But what the coder may do in case the values are stored in a local language?</p>
<p>The visitor asked me how he can use the MySQL <strong>sum()</strong> function in case the data are stored in Unicode format. Well. I do not think MySQL&#8217;s unicode will support the <strong>sum()</strong> function or even if there is one I do not know frankly speaking. So, I thought and developed an alternative solution.</p>
<p>Here is the alternative solution steps:</p>
<ol>
<li>I get the unicode numbers from the database</li>
<li>Convert them to English number</li>
<li>Sum them up or anything like substract, multiply or divide etc</li>
<li>Convert the result to Unicode once again</li>
</ol>
<p>Thus, it looks simple procedure. Right?</p>
<p><span style="color: #800000;"><strong>Before we start I would like to suggest you download the codes from the bottom link of the page and take a look. Because some code may not look as the original one for browser&#8217;s case sensitiveness. So, it is better to look at the original code from the download link below.</strong></span></p>
<p>So,  I wrote a small class to handle the whole procedure and here goes the coding of my class:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>

	<span class="php-keyword">class</span> UnicodeHandler
	<span class="php-brackets">{</span>
		<span class="php-keyword">var</span> <span class="php-var">$dbLink</span>;
		<span class="php-keyword">var</span> <span class="php-var">$sqlQuery</span>;
		<span class="php-keyword">var</span> <span class="php-var">$dbResult</span>;
		<span class="php-keyword">var</span> <span class="php-var">$dbRow</span>;
		<span class="php-keyword">var</span> <span class="php-var">$salary</span>;
		<span class="php-keyword">var</span> <span class="php-var">$bonus</span>;

		<span class="php-comment">/* Use this constructor in case your PHP version is 4. */</span>
		<span class="php-comment">/*
		function UnicodeHandler()
		{
			$this-&gt;dbLink = '';
			$this-&gt;sqlQuery = '';
			$this-&gt;dbResult = '';
			$this-&gt;dbRow = '';
			$this-&gt;mySalary = 0;
			$this-&gt;myBonus = 0;

			$this-&gt;dbLink = mysql_connect('localhost', 'root', '');
			mysql_query(&quot;SET character_set_results=utf8&quot;, $this-&gt;dbLink);
			mb_language('uni');
			mb_internal_encoding('UTF-8');

			mysql_select_db('test', $this-&gt;dbLink);
			mysql_query(&quot;set names 'utf8'&quot;,$this-&gt;dbLink);
		}
		*/</span>

		<span class="php-comment">/* Use this constructor in case your PHP version is 5 or 5+. */</span>
		<span class="php-comment">/* I assume you are using PHP 5 or 5+. */</span>
		<span class="php-function">function</span> __construct<span class="php-brackets">(</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>sqlQuery <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbResult <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbRow <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>mySalary <span class="php-operator">=</span> <span class="php-number">0</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>myBonus <span class="php-operator">=</span> <span class="php-number">0</span>;

			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink <span class="php-operator">=</span> <span class="php-function">mysql_connect</span><span class="php-brackets">(</span><span class="php-string">'localhost'</span>, <span class="php-string">'root'</span>, <span class="php-string">''</span><span class="php-brackets">)</span>;
			<span class="php-function">mysql_query</span><span class="php-brackets">(</span><span class="php-string">&quot;SET character_set_results=utf8&quot;</span>, <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink<span class="php-brackets">)</span>;
			<span class="php-function">mb_language</span><span class="php-brackets">(</span><span class="php-string">'uni'</span><span class="php-brackets">)</span>;
			<span class="php-function">mb_internal_encoding</span><span class="php-brackets">(</span><span class="php-string">'UTF-8'</span><span class="php-brackets">)</span>;

			<span class="php-function">mysql_select_db</span><span class="php-brackets">(</span><span class="php-string">'test'</span>, <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink<span class="php-brackets">)</span>;
			<span class="php-function">mysql_query</span><span class="php-brackets">(</span><span class="php-string">&quot;set names 'utf8'&quot;</span>,<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink<span class="php-brackets">)</span>;
		<span class="php-brackets">}</span>

		<span class="php-function">function</span> displayTotalPayment<span class="php-brackets">(</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-function">mysql_query</span><span class="php-brackets">(</span><span class="php-string">&quot;SET character_set_results=utf8&quot;</span>, <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink<span class="php-brackets">)</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>sqlQuery <span class="php-operator">=</span> <span class="php-string">&quot;SELECT * FROM bangla_number &quot;</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbResult <span class="php-operator">=</span> <span class="php-function">mysql_query</span><span class="php-brackets">(</span><span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>sqlQuery, <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbLink<span class="php-brackets">)</span>;
			<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>total <span class="php-operator">=</span> <span class="php-number">0</span>;
			<span class="php-keyword">while</span><span class="php-brackets">(</span><span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbRow <span class="php-operator">=</span> <span class="php-function">mysql_fetch_object</span><span class="php-brackets">(</span><span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbResult<span class="php-brackets">)</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">echo</span> <span class="php-string">'Employee ID # '</span> <span class="php-operator">.</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbRow<span class="php-operator">-</span><span class="php-operator">&gt;</span>id <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
				<span class="php-keyword">echo</span> <span class="php-string">'Salary: '</span> <span class="php-operator">.</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbRow<span class="php-operator">-</span><span class="php-operator">&gt;</span>salary <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
				<span class="php-keyword">echo</span> <span class="php-string">'Bonus: '</span> <span class="php-operator">.</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbRow<span class="php-operator">-</span><span class="php-operator">&gt;</span>bonus <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
				<span class="php-var">$totalPayment</span> <span class="php-operator">=</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>convertToEnglishNumber<span class="php-brackets">(</span><span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbRow<span class="php-operator">-</span><span class="php-operator">&gt;</span>salary<span class="php-brackets">)</span> <span class="php-operator">+</span>
				<span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>convertToEnglishNumber<span class="php-brackets">(</span><span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>dbRow<span class="php-operator">-</span><span class="php-operator">&gt;</span>bonus<span class="php-brackets">)</span>;
				<span class="php-keyword">echo</span> <span class="php-string">'Total Payment: '</span> <span class="php-operator">.</span> <span class="php-var">$this</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>convertToBanglaNumber<span class="php-brackets">(</span><span class="php-var">$totalPayment</span><span class="php-brackets">)</span> <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
				<span class="php-keyword">echo</span> <span class="php-string">'&lt;br /&gt;&lt;br /&gt;'</span>;
			<span class="php-brackets">}</span>

		<span class="php-brackets">}</span>

		<span class="php-function">function</span> convertToEnglishNumber<span class="php-brackets">(</span><span class="php-var">$unicodeNumber</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>

			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-function">mb_convert_encoding</span><span class="php-brackets">(</span><span class="php-var">$unicodeNumber</span>,<span class="php-string">&quot;HTML-ENTITIES&quot;</span>,<span class="php-string">&quot;UTF-8&quot;</span><span class="php-brackets">)</span>;
			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'&amp;#2534;'</span>, <span class="php-string">'0'</span>, <span class="php-var">$englishNumber</span><span class="php-brackets">)</span>;
			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'&amp;#2535;'</span>, <span class="php-string">'1'</span>, <span class="php-var">$englishNumber</span><span class="php-brackets">)</span>;
			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'&amp;#2536;'</span>, <span class="php-string">'2'</span>, <span class="php-var">$englishNumber</span><span class="php-brackets">)</span>;
			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'&amp;#2537;'</span>, <span class="php-string">'3'</span>, <span class="php-var">$englishNumber</span><span class="php-brackets">)</span>;
			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'&amp;#2538;'</span>, <span class="php-string">'4'</span>, <span class="php-var">$englishNumber</span><span class="php-brackets">)</span>;
			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'&amp;#2539;'</span>, <span class="php-string">'5'</span>, <span class="php-var">$englishNumber</span><span class="php-brackets">)</span>;
			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'&amp;#2540;'</span>, <span class="php-string">'6'</span>, <span class="php-var">$englishNumber</span><span class="php-brackets">)</span>;
			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'&amp;#2541;'</span>, <span class="php-string">'7'</span>, <span class="php-var">$englishNumber</span><span class="php-brackets">)</span>;
			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'&amp;#2542;'</span>, <span class="php-string">'8'</span>, <span class="php-var">$englishNumber</span><span class="php-brackets">)</span>;
			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'&amp;#2543;'</span>, <span class="php-string">'9'</span>, <span class="php-var">$englishNumber</span><span class="php-brackets">)</span>;
			<span class="php-keyword">return</span> <span class="php-var">$englishNumber</span>;
		<span class="php-brackets">}</span>

		<span class="php-function">function</span> convertToBanglaNumber<span class="php-brackets">(</span><span class="php-var">$englishNumber</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-var">$englishNumber</span> <span class="php-operator">=</span> <span class="php-brackets">(</span><span class="php-var-type">string</span><span class="php-brackets">)</span> <span class="php-var">$englishNumber</span>;
			<span class="php-var">$banglaNumber</span> <span class="php-operator">=</span> <span class="php-string">''</span>;
			<span class="php-var">$indexLimit</span> <span class="php-operator">=</span> <span class="php-function">strlen</span><span class="php-brackets">(</span><span class="php-var">$englishNumber</span><span class="php-brackets">)</span>;
			<span class="php-keyword">for</span><span class="php-brackets">(</span><span class="php-var">$i</span><span class="php-operator">=</span><span class="php-number">0</span>; <span class="php-var">$i</span><span class="php-operator">&lt;</span><span class="php-var">$indexLimit</span>; <span class="php-var">$i</span><span class="php-operator">+</span><span class="php-operator">+</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">switch</span><span class="php-brackets">(</span><span class="php-var">$englishNumber</span><span class="php-brackets">[</span><span class="php-var">$i</span><span class="php-brackets">]</span><span class="php-brackets">)</span>
				<span class="php-brackets">{</span>
					<span class="php-keyword">case</span> <span class="php-string">&quot;0&quot;</span><span class="php-operator">:</span>
						<span class="php-var">$banglaNumber</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&amp;#2534;'</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-string">&quot;1&quot;</span><span class="php-operator">:</span>
						<span class="php-var">$banglaNumber</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&amp;#2535;'</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-string">&quot;2&quot;</span><span class="php-operator">:</span>
						<span class="php-var">$banglaNumber</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&amp;#2536;'</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-string">&quot;3&quot;</span><span class="php-operator">:</span>
						<span class="php-var">$banglaNumber</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&amp;#2537;'</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-string">&quot;4&quot;</span><span class="php-operator">:</span>
						<span class="php-var">$banglaNumber</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&amp;#2538;'</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-string">&quot;5&quot;</span><span class="php-operator">:</span>
						<span class="php-var">$banglaNumber</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&amp;#2539;'</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-string">&quot;6&quot;</span><span class="php-operator">:</span>
						<span class="php-var">$banglaNumber</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&amp;#2540;'</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-string">&quot;7&quot;</span><span class="php-operator">:</span>
						<span class="php-var">$banglaNumber</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&amp;#2541;'</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-string">&quot;8&quot;</span><span class="php-operator">:</span>
						<span class="php-var">$banglaNumber</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&amp;#2542;'</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">case</span> <span class="php-string">&quot;9&quot;</span><span class="php-operator">:</span>
						<span class="php-var">$banglaNumber</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-string">'&amp;#2543;'</span>;
						<span class="php-keyword">break</span>;
					<span class="php-keyword">default</span><span class="php-operator">:</span>
						<span class="php-var">$banglaNumber</span> <span class="php-operator">.</span><span class="php-operator">=</span> <span class="php-var">$englishNumber</span><span class="php-brackets">[</span><span class="php-var">$i</span><span class="php-brackets">]</span>;
						<span class="php-keyword">break</span>;
				<span class="php-brackets">}</span>
			<span class="php-brackets">}</span>
			<span class="php-keyword">return</span> <span class="php-var">$banglaNumber</span>;
		<span class="php-brackets">}</span>

	<span class="php-brackets">}</span>

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>If you are not using Bengali language, you need to configure the equivalent number values in <span style="text-decoration: underline;">convertToEnglishNumber</span> and <span style="text-decoration: underline;">convertToBanglaNumber</span> functions.</p>
<p>And here goes the page where I am executing the <span style="text-decoration: underline;">displayTotalPayment()</span> function.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-operator">&lt;</span><span class="php-operator">!</span>DOCTYPE html PUBLIC <span class="php-string">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span class="php-string">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span class="php-operator">&gt;</span>
<span class="php-operator">&lt;</span>html xmlns<span class="php-operator">=</span><span class="php-string">&quot;http://www.w3.org/1999/xhtml&quot;</span><span class="php-operator">&gt;</span>
<span class="php-operator">&lt;</span>head<span class="php-operator">&gt;</span>
<span class="php-operator">&lt;</span>meta http<span class="php-operator">-</span>equiv<span class="php-operator">=</span><span class="php-string">&quot;Content-Type&quot;</span> content<span class="php-operator">=</span><span class="php-string">&quot;text/html; charset=utf-8&quot;</span> <span class="php-operator">/</span><span class="php-operator">&gt;</span>
<span class="php-operator">&lt;</span>title<span class="php-operator">&gt;</span>Unicode Number Adding<span class="php-operator">&lt;</span><span class="php-operator">/</span>title<span class="php-operator">&gt;</span>
<span class="php-operator">&lt;</span><span class="php-operator">/</span>head<span class="php-operator">&gt;</span>

<span class="php-operator">&lt;</span>body<span class="php-operator">&gt;</span>
<span class="php-script-tag">&lt;?php</span>

	<span class="php-keyword">include_once</span> <span class="php-string">'class.unicode.php'</span>;
	<span class="php-var">$salaryObject</span> <span class="php-operator">=</span> <span class="php-keyword">new</span> UnicodeHandler<span class="php-brackets">(</span><span class="php-brackets">)</span>;
	<span class="php-var">$salaryObject</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>displayTotalPayment<span class="php-brackets">(</span><span class="php-brackets">)</span>;

<span class="php-script-tag">?&gt;<span class="html">
<span class="html-other-element">&lt;/body&gt;</span>
<span class="html-other-element">&lt;/html&gt;</span></span></span></span></pre>
</div>
<p>Now the final result looks like this:</p>
<p><a href="http://www.tanzilo.com/wp-content/uploads/2008/12/add_bangla_number.jpg"><img class="alignleft size-full wp-image-61" style="float:none;" title="add_bangla_number" src="http://www.tanzilo.com/wp-content/uploads/2008/12/add_bangla_number.jpg" alt="" width="210" height="531" /></a></p>
<p>Oh! One important thing. If you are coding for European number format, you need to do some modification to handle the comma (,) factor in the number in case required.</p>
<p>Thus, if you use this small tricky method, you can add, subtract,  multiply or divide any local numbers such as Russian, Chinese, Arabic, Spanish, German, Polish, Turkey, Hindi etc.</p>
<p>You can also download this small piece of code from here:<br />
<a title="unicode number add" href="http://www.tanzilo.com/demo/code/unicode_number_add/unicode_number_add.zip" target="_blank">http://www.tanzilo.com/demo/code/unicode_number_add/unicode_number_add.zip</a></p>
<p>Thank you for reading.</p>
<p><map name='google_ad_map_60_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/60?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_60_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=60&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2008%2F12%2F23%2Fphp-mysql-unicode-number-add-subtract-etc-for-any-language%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2008/12/23/php-mysql-unicode-number-add-subtract-etc-for-any-language/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>WordPress: get page id and content with example &amp; code</title>
		<link>http://www.tanzilo.com/2008/12/19/wordpress-get-page-id-and-content-with-example-code/</link>
		<comments>http://www.tanzilo.com/2008/12/19/wordpress-get-page-id-and-content-with-example-code/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 16:44:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[id]]></category>
		<category><![CDATA[page content]]></category>
		<category><![CDATA[page id]]></category>
		<category><![CDATA[print]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=58</guid>
		<description><![CDATA[Hey Guys! Often I see people coming to my site searching with the terms wordpress get page id, wordpress get page content or something similar. I think wordpress developers face situations when they need to get page or post information in customized way. It happened to me too and I would like to share it [...]]]></description>
			<content:encoded><![CDATA[<p>Hey Guys!</p>
<p>Often I see people coming to my site searching with the terms <span style="text-decoration: underline;"><strong>wordpress get page id</strong></span>, <span style="text-decoration: underline;"><strong>wordpress get page content</strong></span> or something similar. I think wordpress developers face situations when they need to get page or post information in customized way. It happened to me too and I would like to share it with others since often people are coming to search this information.</p>
<p>Well. It is very easy and we can solve it quickly.<br />
OK. Now let me show you how to get these information.</p>
<p>Remember one thing that is important for wordpress data fetching of this kind. Your posts and pages information is saved in a single database table and that is <strong>wp_posts</strong>. The <strong>wp_</strong> is the prefix of you database and may differ. But most of the times the database table name is <strong>wp_posts</strong> and other times it is <strong>YourCustomPrefix_posts</strong>. We are going to fetch data from this table.</p>
<p><span style="text-decoration: underline;"><strong>WordPress &#8211; print page id:</strong></span></p>
<p>There is a built-in wordpress function using which you can print the post or page id. When you call this, this directly prints this inforation in your page without the need to use the built-in PHP <span style="text-decoration: underline;"><strong>echo</strong></span> or <span style="text-decoration: underline;"><strong>print</strong></span> function. Remember to keep it in the while loop.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span> <span class="php-keyword">if</span> <span class="php-brackets">(</span>have_posts<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">:</span> <span class="php-script-tag">?&gt;<span class="html">

	</span>&lt;?php</span> <span class="php-keyword">while</span> <span class="php-brackets">(</span>have_posts<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">:</span> the_post<span class="php-brackets">(</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">

		</span>&lt;?php</span> the_ID<span class="php-brackets">(</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">

	</span>&lt;?php</span> <span class="php-keyword">endwhile</span>; <span class="php-script-tag">?&gt;<span class="html">

</span>&lt;?php</span> <span class="php-keyword">endif</span>; <span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p><span style="text-decoration: underline;"><strong>WordPress &#8211; get page id:</strong></span></p>
<p>There is a global variable post which contains the related information of the currest post or page. The name of the variable is: <span style="text-decoration: underline;">$post</span> and it is actually an object. You can access information just as you access variables from an object. Remember to keep it in the while loop.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span> <span class="php-keyword">if</span> <span class="php-brackets">(</span>have_posts<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">:</span> <span class="php-script-tag">?&gt;<span class="html">

	</span>&lt;?php</span> <span class="php-keyword">while</span> <span class="php-brackets">(</span>have_posts<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">:</span> the_post<span class="php-brackets">(</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">

        </span>&lt;?php</span>
		<span class="php-keyword">global</span> <span class="php-var">$post</span>;
		<span class="php-keyword">echo</span> <span class="php-var">$post</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>ID;
        <span class="php-script-tag">?&gt;<span class="html">

	</span>&lt;?php</span> <span class="php-keyword">endwhile</span>; <span class="php-script-tag">?&gt;<span class="html">

</span>&lt;?php</span> <span class="php-keyword">endif</span>; <span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>You can print all the information in the $post object to see all the variables and their values that is contains.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span> <span class="php-keyword">if</span> <span class="php-brackets">(</span>have_posts<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">:</span> <span class="php-script-tag">?&gt;<span class="html">

	</span>&lt;?php</span> <span class="php-keyword">while</span> <span class="php-brackets">(</span>have_posts<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">:</span> the_post<span class="php-brackets">(</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">

        </span>&lt;?php</span>
		<span class="php-keyword">global</span> <span class="php-var">$post</span>;
		<span class="php-function">var_dump</span><span class="php-brackets">(</span><span class="php-var">$post</span><span class="php-brackets">)</span>;
        <span class="php-script-tag">?&gt;<span class="html">

	</span>&lt;?php</span> <span class="php-keyword">endwhile</span>; <span class="php-script-tag">?&gt;<span class="html">

</span>&lt;?php</span> <span class="php-keyword">endif</span>; <span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p><span style="text-decoration: underline;"><strong>WordPress &#8211; get page content:</strong></span></p>
<p>Now you know you can get the page or post content from $post-&gt;post_content variable. But if you echo or print them, they may look somewhat without formatting. So, you need to use PHP built-in <strong>nl2br()</strong> function to look the content as it is.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span> <span class="php-keyword">if</span> <span class="php-brackets">(</span>have_posts<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">:</span> <span class="php-script-tag">?&gt;<span class="html">

	</span>&lt;?php</span> <span class="php-keyword">while</span> <span class="php-brackets">(</span>have_posts<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">:</span> the_post<span class="php-brackets">(</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">

        </span>&lt;?php</span>
		<span class="php-keyword">global</span> <span class="php-var">$post</span>;
		<span class="php-keyword">echo</span> <span class="php-function">nl2br</span><span class="php-brackets">(</span><span class="php-var">$post</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>post_content<span class="php-brackets">)</span>;
        <span class="php-script-tag">?&gt;<span class="html">

	</span>&lt;?php</span> <span class="php-keyword">endwhile</span>; <span class="php-script-tag">?&gt;<span class="html">

</span>&lt;?php</span> <span class="php-keyword">endif</span>; <span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p><span style="text-decoration: underline;"><strong>WordPress &#8211; get any information of your page or post:</strong></span></p>
<p>You know you can print all information to check all the available variables and their values through using PHP&#8217;s built-in <strong>var_dump()</strong> function. Suppose you need to get the post title, post type and posting time. We can get them easily in this way.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span> <span class="php-keyword">if</span> <span class="php-brackets">(</span>have_posts<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">:</span> <span class="php-script-tag">?&gt;<span class="html">

	</span>&lt;?php</span> <span class="php-keyword">while</span> <span class="php-brackets">(</span>have_posts<span class="php-brackets">(</span><span class="php-brackets">)</span><span class="php-brackets">)</span> <span class="php-operator">:</span> the_post<span class="php-brackets">(</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">

        </span>&lt;?php</span>
		<span class="php-keyword">global</span> <span class="php-var">$post</span>;
		<span class="php-keyword">echo</span> <span class="php-var">$post</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>post_title;
		<span class="php-keyword">echo</span> <span class="php-var">$post</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>post_type;
		<span class="php-keyword">echo</span> <span class="php-var">$post</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>post_date;
        <span class="php-script-tag">?&gt;<span class="html">

	</span>&lt;?php</span> <span class="php-keyword">endwhile</span>; <span class="php-script-tag">?&gt;<span class="html">

</span>&lt;?php</span> <span class="php-keyword">endif</span>; <span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>Please notice that post_title, post_type and post_date are all several database fields from <strong>wp_posts</strong> table of our wordpress database.</p>
<p>Very easy. Right? And that is all for getting the page or post information.</p>
<p>Thank you for reading.</p>
<p><map name='google_ad_map_58_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/58?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_58_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=58&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2008%2F12%2F19%2Fwordpress-get-page-id-and-content-with-example-code%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2008/12/19/wordpress-get-page-id-and-content-with-example-code/feed/</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
		<item>
		<title>WordPress: Custom URL rewrite and reading URL values</title>
		<link>http://www.tanzilo.com/2008/12/17/wordpress-custom-url-rewrite-and-reading-url-values/</link>
		<comments>http://www.tanzilo.com/2008/12/17/wordpress-custom-url-rewrite-and-reading-url-values/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 20:48:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Custom]]></category>
		<category><![CDATA[read]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[values]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=59</guid>
		<description><![CDATA[Hello! Recently I was working for a Irish guy who has opened a wordpress blog few months ago. I did the theme for him. Recently he requested me for modifying and/or upgrading the project. One of the project requirements was URL rewriting. For example, there can a URL as follows: http://www.sitename.com/index.php?group_name=My-Input-Value-Goes-Here But after rewrite, the [...]]]></description>
			<content:encoded><![CDATA[<p>Hello!</p>
<p>Recently I was working for a Irish guy who has opened a wordpress blog few months ago. I did the theme for him. Recently he requested me for modifying and/or upgrading the project. One of the project requirements was URL rewriting. For example, there can a URL as follows:<br />
<strong>http://www.sitename.com/index.php?group_name=My-Input-Value-Goes-Here</strong></p>
<p>But after rewrite, the URL should look like:<br />
<strong>http://www.sitename.com/My-Input-Value-Goes-Here</strong></p>
<p>Well. You see I am passing the variable value in <span style="text-decoration: underline;">index.php</span> file. But I needed to read the custom URL passed value through another PHP file and that is <span style="text-decoration: underline;">group.php</span>. My <span style="text-decoration: underline;">group.php</span> file was inside the theme folder. I am passing the <strong>group_name</strong> value in <span style="text-decoration: underline;">index.php</span> file but reading from <span style="text-decoration: underline;">group.php</span> file. It sounds a bit interesting. Huh?</p>
<p>OK. After browsing several blogs, I came up to writing a custom plugin. Thanks to Google.com and all those people sharing information.</p>
<p>My plugin made me a way so that I could pass a variable value in <span style="text-decoration: underline;">index.php</span> file but read it from <span style="text-decoration: underline;">group.php</span> file. This plugin code is available almost everywhere. Here goes my plugin:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span>

	<span class="php-comment">/*
	Plugin Name: WP Custom URL
	Plugin URI: http://www.tanzilo.com/#
	Description: A plugin to allow parameters to be passed in the URL and recognized by WordPress
	Author: Tanzilo
	Version: 1.0
	Author URI: http://www.tanzilo.com/
	*/</span>

	<span class="php-function">function</span> flush_rewrite_rules<span class="php-brackets">(</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-keyword">global</span> <span class="php-var">$wp_rewrite</span>;
		<span class="php-var">$wp_rewrite</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>flush_rules<span class="php-brackets">(</span><span class="php-brackets">)</span>;
	<span class="php-brackets">}</span>

	<span class="php-function">function</span> add_rewrite_rules<span class="php-brackets">(</span> <span class="php-var">$wp_rewrite</span> <span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-var">$new_rules</span> <span class="php-operator">=</span> <span class="php-keyword">array</span><span class="php-brackets">(</span>
	  		<span class="php-string">'(.+)'</span> <span class="php-operator">=</span><span class="php-operator">&gt;</span> <span class="php-string">'index.php?group_name='</span> <span class="php-operator">.</span>
			<span class="php-var">$wp_rewrite</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>preg_index<span class="php-brackets">(</span><span class="php-number">1</span><span class="php-brackets">)</span> <span class="php-brackets">)</span>;

		<span class="php-var">$wp_rewrite</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>rules <span class="php-operator">=</span> <span class="php-var">$new_rules</span> <span class="php-operator">+</span> <span class="php-var">$wp_rewrite</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>rules;
	<span class="php-brackets">}</span>

	<span class="php-function">function</span> add_query_vars<span class="php-brackets">(</span> <span class="php-var">$qvars</span> <span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-var">$qvars</span><span class="php-brackets">[</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-string">'group_name'</span>;
		<span class="php-keyword">return</span> <span class="php-var">$qvars</span>;
	<span class="php-brackets">}</span>

	<span class="php-function">function</span> template_redirect_file<span class="php-brackets">(</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-keyword">global</span> <span class="php-var">$wp_query</span>;
		<span class="php-keyword">if</span> <span class="php-brackets">(</span> <span class="php-var">$wp_query</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>get<span class="php-brackets">(</span><span class="php-string">'group_name'</span><span class="php-brackets">)</span> <span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-keyword">if</span> <span class="php-brackets">(</span><span class="php-function">file_exists</span><span class="php-brackets">(</span> TEMPLATEPATH <span class="php-operator">.</span> <span class="php-string">'/group.php'</span> <span class="php-brackets">)</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">include</span><span class="php-brackets">(</span> TEMPLATEPATH <span class="php-operator">.</span> <span class="php-string">'/group.php'</span> <span class="php-brackets">)</span>;
				<span class="php-function">exit</span>;
			<span class="php-brackets">}</span>
		<span class="php-brackets">}</span>
	<span class="php-brackets">}</span>

	add_action<span class="php-brackets">(</span><span class="php-string">'init'</span>, <span class="php-string">'flush_rewrite_rules'</span><span class="php-brackets">)</span>;
	add_action<span class="php-brackets">(</span><span class="php-string">'generate_rewrite_rules'</span>, <span class="php-string">'add_rewrite_rules'</span><span class="php-brackets">)</span>;
	add_filter<span class="php-brackets">(</span><span class="php-string">'query_vars'</span>, <span class="php-string">'add_query_vars'</span><span class="php-brackets">)</span>;
	add_action<span class="php-brackets">(</span><span class="php-string">'template_redirect'</span>, <span class="php-string">'template_redirect_file'</span><span class="php-brackets">)</span>;

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>So, what happens now when I activate this plugin? It does a simple work and that is: when it gets a link as below:<br />
<strong>http://www.sitename.com/index.php?group_name=My-Input-Value-Goes-Here</strong></p>
<p>It sends the <strong>group_name</strong> variable value to <span style="text-decoration: underline;">group.php</span> file which is in the theme folder. In <strong>group.php</strong> file, I can catch the variable value and use it anyway I want.</p>
<p>Do you want to see my <span style="text-decoration: underline;">group.php</span> file too? OK. Here it goes:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span> get_header<span class="php-brackets">(</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">

	</span>&lt;?php</span>

		<span class="php-var">$group_name</span> <span class="php-operator">=</span> <span class="php-var">$_GET</span><span class="php-brackets">[</span><span class="php-string">'group_name'</span><span class="php-brackets">]</span>;
		<span class="php-var">$group_name</span> <span class="php-operator">=</span> <span class="php-function">str_replace</span><span class="php-brackets">(</span><span class="php-string">'-'</span>, <span class="php-string">' '</span>, <span class="php-var">$group_name</span><span class="php-brackets">)</span>;

	<span class="php-script-tag">?&gt;<span class="html">

	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;container&quot;</span>&gt;</span>
    	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;contentLeft&quot;</span>&gt;</span>
        	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;pageContent&quot;</span>&gt;</span>

            	<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;postTitle&quot;</span>&gt;</span></span>&lt;?php</span> <span class="php-keyword">echo</span> <span class="php-var">$group_name</span>; <span class="php-script-tag">?&gt;<span class="html"><span class="html-other-element">&lt;/div&gt;</span>
                <span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;postContent&quot;</span>&gt;</span></span>&lt;?php</span> the_time<span class="php-brackets">(</span><span class="php-string">'F j, Y'</span><span class="php-brackets">)</span> <span class="php-script-tag">?&gt;<span class="html"><span class="html-other-element">&lt;br /&gt;</span>
                    <span class="html-other-element">&lt;ul id=<span class="html-attribute">&quot;pageGroupLinks&quot;</span>&gt;</span>
                        </span>&lt;?php</span> <span class="php-keyword">echo</span> getGroupPageLinks<span class="php-brackets">(</span><span class="php-var">$group_name</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">
                    <span class="html-other-element">&lt;/ul&gt;</span>
				<span class="html-other-element">&lt;/div&gt;</span>
                <span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;rssSubscribe&quot;</span>&gt;</span>If you enjoyed this post, make sure you
                <span class="html-anchor-element">&lt;a href=<span class="html-attribute">&quot;</span></span></span>&lt;?php</span> bloginfo<span class="php-brackets">(</span><span class="php-string">'rss2_url'</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">&quot;&gt;subscribe to our RSS feed!<span class="html-anchor-element">&lt;/a&gt;</span>
                <span class="html-other-element">&lt;/div&gt;</span>

            <span class="html-other-element">&lt;/div&gt;</span>

        <span class="html-other-element">&lt;/div&gt;</span>

	</span>&lt;?php</span> get_sidebar<span class="php-brackets">(</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html">

    <span class="html-other-element">&lt;/div&gt;</span>

	</span>&lt;?php</span> get_footer<span class="php-brackets">(</span><span class="php-brackets">)</span>; <span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>This was half the way winning the battle.</p>
<p>But why? Because the following lines should solve my problem.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre>
<pre><span class="php"><span class="php-function">function</span> add_rewrite_rules<span class="php-brackets">(</span> <span class="php-var">$wp_rewrite</span> <span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-var">$new_rules</span> <span class="php-operator">=</span> <span class="php-keyword">array</span><span class="php-brackets">(</span>
	  		<span class="php-string">'(.+)'</span> <span class="php-operator">=</span><span class="php-operator">&gt;</span> <span class="php-string">'index.php?group_name='</span> <span class="php-operator">.</span>
			<span class="php-var">$wp_rewrite</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>preg_index<span class="php-brackets">(</span><span class="php-number">1</span><span class="php-brackets">)</span> <span class="php-brackets">)</span>;

		<span class="php-var">$wp_rewrite</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>rules <span class="php-operator">=</span> <span class="php-var">$new_rules</span> <span class="php-operator">+</span> <span class="php-var">$wp_rewrite</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>rules;
	<span class="php-brackets">}</span></span></pre>
</div>
<p>But for any unknown reason it was not working.</p>
<p>So, I had to take help of apache <span style="text-decoration: underline;">(dot)htaccess</span> file for solving the rest of the part.</p>
<p>I was searching for a helpful blog link and after searching many blogs, I found a similar blog article and here it is:</p>
<p><a title="URL ReWriting Link" href="http://www.webmasterworld.com/forum92/6079.htm" target="_blank">http://www.webmasterworld.com/forum92/6079.htm</a></p>
<p>In this blog, I found a similar solution and wrote my own based on this code.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre>
<pre><span class="html"># Enable mod_rewrite, start rewrite engine
Options +FollowSymLinks
RewriteEngine on
#
# Internally rewrite search engine friendly static URL to dynamic filepath and query
RewriteRule ^product/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?product=$1<span class="html-special-char">&amp;color=$2&amp;size=$3&amp;texture=$4&amp;maker=$5 </span>[L]
#
# Externally redirect client requests for old dynamic URLs to equivalent new static URLs
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?product=([^<span class="html-special-char">&amp;]+)&amp;color=([^&amp;]+)&amp;size=([^&amp;]+)&amp;texture=([^&amp;]+)&amp;maker=([^\ </span>]+)\ HTTP/
RewriteRule ^index\.php$ http://example.com/product/%1/%2/%3/%4/%5? [R=301,L]</span></pre>
</div>
<p>Finally my <span style="text-decoration: underline;">(dot)htaccess</span> file looked like this:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="html"># BEGIN WordPress
<span class="html-other-element">&lt;IfModule mod_rewrite.c&gt;</span>
RewriteEngine On
RewriteBase /

RewriteRule ^pages/([^/]+)/?$ /index.php?group_name=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?group_name=([^<span class="html-special-char">&amp;]+)\ </span>HTTP/
RewriteRule ^index\.php$ http://mobile.ie/pages/%1? [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
<span class="html-other-element">&lt;/IfModule&gt;</span>

# END WordPress</span></pre>
</div>
<p>But I was not 100% perfect but close to the solution. The reason is my URL started looking like this:<br />
<strong>http://www.sitename.com/pages/My-Input-Value-Goes-Here</strong></p>
<p>Well. You see I was almost close to the solution. As the buyer wanted like this:<br />
<strong>http://www.sitename.com/My-Input-Value-Goes-Here</strong></p>
<p>But I came up with a solution to:<br />
<strong>http://www.sitename.com/pages/My-Input-Value-Goes-Here</strong></p>
<p>I believe you can work on it and come to a solution without the extra &#8220;<strong>pages/</strong>&#8221; part in the URL. If you find such a solution, please share with me and others who will face similar problem.</p>
<p>Dude! That is all for now.</p>
<p>Thank you for reading.</p>
<p><map name='google_ad_map_59_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/59?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_59_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=59&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2008%2F12%2F17%2Fwordpress-custom-url-rewrite-and-reading-url-values%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2008/12/17/wordpress-custom-url-rewrite-and-reading-url-values/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>WordPress: Upload many PHP files quickly by Zip &amp; Unzip</title>
		<link>http://www.tanzilo.com/2008/12/15/wordpress-upload-many-php-files-quickly-by-zip-unzip/</link>
		<comments>http://www.tanzilo.com/2008/12/15/wordpress-upload-many-php-files-quickly-by-zip-unzip/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 21:29:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[fast]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[many]]></category>
		<category><![CDATA[quickly]]></category>
		<category><![CDATA[Upload]]></category>

		<guid isPermaLink="false">http://www.tanzilo.com/?p=56</guid>
		<description><![CDATA[Hello! It is actually not only for a wordpress developer but also for all those developers who face situation where they must upload many files to the server. Recently in a wordpress project, I had to upload wordpress 2.7 version files in the server. In the wordpress 2.7 package, you will find around 600 files! [...]]]></description>
			<content:encoded><![CDATA[<p>Hello!</p>
<p>It is actually not only for a wordpress developer but also for all those developers who face situation where they must upload many files to the server. Recently in a wordpress project, I had to upload wordpress 2.7 version files in the server. In the wordpress 2.7 package, you will find around 600 files! Uploading them is not very interesting when your internet connection do not guarantee you smooth upload.</p>
<p>Uploading the 600 files brought me pain because they were going to the server very slowly and each time some files were corrupted and for any reason reuploading the corrupted files were not working. It was really time consuming, boring and painful. Then I started to look for an alternative solution. Then, I naturally came to the idea that how about I zip (compress) the folders containing most of the files and upload them. Thus I have to upload few zip files although bigger in size. Writing a piece of PHP code to unzip the zipped file is easy too.</p>
<p>So, I decided to zip the main three folders and uploaded them. You know they contain most of the files.</p>
<p>OK. Let me tell you the process in step by step way so that you can follow easily:</p>
<ol>
<li>First I zipped my three folders (<strong>wp-admin</strong>, <strong>wp-content</strong> &amp; <strong>wp-includes</strong>) that contains most of the files.</li>
<li>Changed the &#8216;<span style="text-decoration: underline;"><strong>public_html</strong></span>&#8216; folder permission to 777. Remember you will do it for the folder where you are going to upload.</li>
<li>Uploaded the three zipped folders.</li>
<li>Run my PHP script that you will see below.</li>
<li>Checked if everything is OK and found them OK.</li>
<li>Changed the file permission of the &#8216;<span style="text-decoration: underline;"><strong>public_html</strong></span>&#8216; folder back to 750. If you uploaded to any other folder, you need to change the permission 777 to any combination you think good for your purpose.</li>
<li>Deleted the zip files since they are no longer required.</li>
</ol>
<p>Here goes my PHP code to unzip them and it is very simple!</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span> 

	<span class="php-var">$zipFileNames</span> <span class="php-operator">=</span> <span class="php-keyword">array</span><span class="php-brackets">(</span><span class="php-brackets">)</span>;
	<span class="php-var">$zipFileNames</span><span class="php-brackets">[</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-string">'wp-admin.zip'</span>;
	<span class="php-var">$zipFileNames</span><span class="php-brackets">[</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-string">'wp-content.zip'</span>;
	<span class="php-var">$zipFileNames</span><span class="php-brackets">[</span><span class="php-brackets">]</span> <span class="php-operator">=</span> <span class="php-string">'wp-includes.zip'</span>;
	<span class="php-comment">// and all other zip files
</span>

	<span class="php-var">$indexLimit</span> <span class="php-operator">=</span> <span class="php-function">count</span><span class="php-brackets">(</span><span class="php-var">$zipFileNames</span><span class="php-brackets">)</span>;
	<span class="php-keyword">for</span><span class="php-brackets">(</span><span class="php-var">$i</span><span class="php-operator">=</span><span class="php-number">0</span>; <span class="php-var">$i</span><span class="php-operator">&lt;</span><span class="php-var">$indexLimit</span>; <span class="php-var">$i</span><span class="php-operator">+</span><span class="php-operator">+</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-var">$fileLink</span> <span class="php-operator">=</span> <span class="php-var">$_SERVER</span><span class="php-brackets">[</span><span class="php-string">'DOCUMENT_ROOT'</span><span class="php-brackets">]</span> <span class="php-operator">.</span> <span class="php-string">'/'</span> <span class="php-operator">.</span> <span class="php-var">$zipFileNames</span><span class="php-brackets">[</span><span class="php-var">$i</span><span class="php-brackets">]</span>;
		<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-function">is_file</span><span class="php-brackets">(</span><span class="php-var">$fileLink</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
		<span class="php-brackets">{</span>
			<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-function">exec</span><span class="php-brackets">(</span><span class="php-string">&quot;unzip $fileLink&quot;</span><span class="php-brackets">)</span><span class="php-brackets">)</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">echo</span> <span class="php-string">'Successful! '</span> <span class="php-operator">.</span> <span class="php-var">$fileLink</span> <span class="php-operator">.</span> <span class="php-string">' is properly unzipped!'</span> <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
			<span class="php-brackets">}</span>
			<span class="php-keyword">else</span>
			<span class="php-brackets">{</span>
				<span class="php-keyword">echo</span> <span class="php-string">'Failed! exec() failed to execute as expected!'</span> <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span> <span class="php-operator">.</span>
				<span class="php-string">'Please check if the directory permission is 777 where you are trying upload.'</span>;
			<span class="php-brackets">}</span>
		<span class="php-brackets">}</span>
		<span class="php-keyword">else</span>
		<span class="php-brackets">{</span>
			<span class="php-keyword">echo</span> <span class="php-string">'Error: '</span> <span class="php-operator">.</span> <span class="php-var">$fileLink</span> <span class="php-operator">.</span> <span class="php-string">' is not a (zip) file!'</span> <span class="php-operator">.</span> <span class="php-string">'&lt;br /&gt;'</span>;
		<span class="php-brackets">}</span>
	<span class="php-brackets">}</span>

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>By the way, you can improve the code to more sophisticated one as per your requirement. For example, the <strong>exec()</strong> function has several options that you can use for more flexibility or anyway anything else you want.</p>
<p>Oh! There is one other way to unzip a uploaded zipped file although I did not use this piece of code. But remember that if you use this code you need to set your destination file permission to &#8217;777&#8242; first and then change as mentioned before after you unzipped. Fortunately this coding is very simple too and an example is as follows:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
</pre>
<pre><span class="php"><span class="php-script-tag">&lt;?php</span> 

	<span class="php-var">$zip</span> <span class="php-operator">=</span> <span class="php-keyword">new</span> ZipArchive;

	<span class="php-keyword">if</span><span class="php-brackets">(</span><span class="php-var">$zip</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>open<span class="php-brackets">(</span><span class="php-var">$_SERVER</span><span class="php-brackets">[</span><span class="php-string">'DOCUMENT_ROOT'</span><span class="php-brackets">]</span> <span class="php-operator">.</span> <span class="php-string">'/hello.zip'</span><span class="php-brackets">)</span> <span class="php-operator">=</span><span class="php-operator">=</span><span class="php-operator">=</span> <span class="php-keyword">true</span><span class="php-brackets">)</span>
	<span class="php-brackets">{</span>
		<span class="php-var">$zip</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>extractto<span class="php-brackets">(</span><span class="php-var">$_SERVER</span><span class="php-brackets">[</span><span class="php-string">'DOCUMENT_ROOT'</span><span class="php-brackets">]</span> <span class="php-operator">.</span> <span class="php-string">'/hellotest/'</span><span class="php-brackets">)</span>;
		<span class="php-var">$zip</span><span class="php-operator">-</span><span class="php-operator">&gt;</span>close<span class="php-brackets">(</span><span class="php-brackets">)</span>;
		<span class="php-keyword">echo</span> <span class="php-string">'Files successfully unzipped!'</span>;
	<span class="php-brackets">}</span>
	<span class="php-keyword">else</span>
	<span class="php-brackets">{</span>
		<span class="php-function">die</span><span class="php-brackets">(</span><span class="php-string">'Failed to open zip file'</span><span class="php-brackets">)</span>;
	<span class="php-brackets">}</span> 

<span class="php-script-tag">?&gt;<span class="html"></span></span></span></pre>
</div>
<p>I tested both the processes mentioned above in Linux system and not sure how it works in Windows Server. I guess the second process should work in Windows server for uploading and unzipping bulk file quickly.</p>
<p>This is all for the trick of the game and for killing the pain of uploading several hundred of files.</p>
<p>Well. You can download my little sweet code here too:<br />
<a title="Wordpress: Upload many PHP files quickly by Zip &amp; Unzip" href="http://www.tanzilo.com/demo/code/unzip/unzipping.zip" target="_blank">http://www.tanzilo.com/demo/code/unzip/unzipping.zip</a></p>
<p>Thank you for reading.</p>
<p><map name='google_ad_map_56_eaab367e2f0158c1'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/56?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_56_eaab367e2f0158c1' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=56&amp;url= http%3A%2F%2Fwww.tanzilo.com%2F2008%2F12%2F15%2Fwordpress-upload-many-php-files-quickly-by-zip-unzip%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.tanzilo.com/2008/12/15/wordpress-upload-many-php-files-quickly-by-zip-unzip/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

