<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" gd:etag="W/&quot;C0IESXkzfyp7ImA9WhdSGEs.&quot;"><id>tag:blogger.com,1999:blog-37793319</id><updated>2011-07-28T09:58:28.787-04:00</updated><category term="seo" /><category term="vb6" /><category term="traffic generation" /><category term="technology" /><category term="the net" /><category term="javascript" /><category term="SQL" /><category term="c/c++" /><category term="java" /><category term="mysql" /><category term="php" /><category term="ajax" /><category term="adsense" /><category term="html" /><category term="make money online" /><category term="programming" /><category term="tutorial" /><category term="everyday life" /><category term="gadget" /><category term="ramblings" /><category term="blogging" /><category term="bloggers corner" /><category term="database" /><category term="oracle" /><title>Practical Web Programming</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>263</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/LifeOfAProgrammer" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="lifeofaprogrammer" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">LifeOfAProgrammer</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;AkQHSHs-fSp7ImA9WxNUEEk.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-486195500694142282</id><published>2009-10-31T22:51:00.004-04:00</published><updated>2009-11-01T00:05:39.555-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-01T00:05:39.555-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: How to Get the Week Day Dates</title><content type="html">In PHP, Getting THE week day dates is not really that difficult. Using a combination of pre-defined PHP functions, you can achieve this. Here's how.&lt;br /&gt;&lt;br /&gt;In this example function, I'll use Sunday as the start of the week. The function will accept the year, month and day - the day should be a Sunday, Ex: 2009, 10 and 25.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&lt;br /&gt;//FUNCTION TO GET THE WEEK DAY DATES&lt;br /&gt;function get_week_day_dates($year, $month, $day)&lt;br /&gt;{&lt;br /&gt;    $start_of_week = mktime(0, 0, 0, $month, $day+(0-(int)date('w')), $year);&lt;br /&gt;    for ($x=0; $x&lt;7; $x++) &lt;br /&gt;    {&lt;br /&gt;        print date('Y-m-d', $start_of_week + $x * 60 * 60 * 24) ."&amp;lt;br/&amp;gt;";&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//USING THE FUNCTION&lt;br /&gt;get_week_day_dates(2009, 10, 25);&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-486195500694142282?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/486195500694142282/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=486195500694142282" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/486195500694142282?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/486195500694142282?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/10/php-how-to-get-week-day-dates.html" title="PHP: How to Get the Week Day Dates" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;CEUFSXk9eip7ImA9WxVWF0Q.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-6733001187285504079</id><published>2009-02-27T21:38:00.002-05:00</published><updated>2009-02-27T22:36:58.762-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-27T22:36:58.762-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>How to Pass Value from Javascript to PHP</title><content type="html">Although JavaScript and PHP is not the same technology, JavaScript being a client-side technology and PHP a server-side, you can actually pass values from PHP to JavaScript and vice-versa. To do this, all you need is to use a &lt;a href="http://en.wikipedia.org/wiki/HTTP_cookie"&gt;cookie&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In this example source code, I will create a cookie in JavaScript and retrieve the cookie value using PHP. Read on.&lt;br /&gt;&lt;br /&gt;JavaScript code to create cookie.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;script type='text/javascript'&amp;gt;&lt;br /&gt; function createCookie(name, value,expiredays)&lt;br /&gt;  {&lt;br /&gt;  var expiry_date = new Date();&lt;br /&gt;  expiry_date.setDate(expiry_date.getDate() + expiredays);&lt;br /&gt;  document.cookie=name+ "=" +escape(value)+&lt;br /&gt;                                           ((expiredays==null) ? "" &lt;br /&gt;                                           :";expires="+expiry_date.toGMTString());&lt;br /&gt;  alert("'" + name + "' cookie created.");&lt;br /&gt;  }&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;HTML code to call the &lt;code&gt;createCookie&lt;/code&gt; function.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;input type="button" value="Create Cookie using JavaScript" &lt;br /&gt;                        onclick="createCookie('YourName', 'Joel Badinas')"/&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;HTML form for submitting request to the server for the PHP code.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;form method="POST" action=""&amp;gt; &lt;br /&gt;&amp;lt;p&amp;gt;&lt;br /&gt;&amp;lt;input type="submit" name="submit" value="Get Cookie using PHP"/&amp;gt;&lt;br /&gt;&amp;lt;/p&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;PHP code that will read the cookie.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;if (isset($_POST["submit"]))&lt;br /&gt; {&lt;br /&gt; print "Cookie value is '".$_COOKIE["YourName"]."'";&lt;br /&gt; }&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Putting it all together.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;lt;title&amp;gt;Practical Web Programming&amp;lt;/title&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script type='text/javascript'&amp;gt;&lt;br /&gt; function createCookie(name, value,expiredays)&lt;br /&gt;  {&lt;br /&gt;  var expiry_date = new Date();&lt;br /&gt;  expiry_date.setDate(expiry_date.getDate() + expiredays);&lt;br /&gt;  document.cookie=name+ "=" +escape(value)+&lt;br /&gt;                                           ((expiredays==null) ? "" &lt;br /&gt;                                           :";expires="+expiry_date.toGMTString());&lt;br /&gt;  alert("'" + name + "' cookie created.");&lt;br /&gt;  }&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/style&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;p method="POST" action=""&amp;gt; &lt;br /&gt;&amp;lt;p&amp;gt;&lt;br /&gt;&amp;lt;input type="button" value="Create Cookie using JavaScript" &lt;br /&gt;                        onclick="createCookie('YourName', 'Joel Badinas')"/&amp;gt;&lt;br /&gt;&amp;lt;input type="submit" name="submit" value="Get Cookie using PHP"/&amp;gt;&lt;br /&gt;&amp;lt;/p&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;if (isset($_POST["submit"]))&lt;br /&gt; {&lt;br /&gt; print "Cookie value is '".$_COOKIE["YourName"]."'";&lt;br /&gt; }&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;There you have it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-6733001187285504079?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/6733001187285504079/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=6733001187285504079" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/6733001187285504079?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/6733001187285504079?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/02/how-to-pass-value-from-javascript-to.html" title="How to Pass Value from Javascript to PHP" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;C0AGRHw_eip7ImA9WxVWEU0.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-7896085066941806493</id><published>2009-02-19T22:40:00.006-05:00</published><updated>2009-02-19T22:48:45.242-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-19T22:48:45.242-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: How to Get the Time Elaped</title><content type="html">Using PHP's &lt;code&gt;&lt;a href="http://us2.php.net/manual/en/function.time.php"&gt;time&lt;/a&gt;&lt;/code&gt; function, you can get the time elapsed of any process in your web application. The &lt;code&gt;&lt;a href="http://us2.php.net/manual/en/function.time.php"&gt;time&lt;/a&gt;&lt;/code&gt; function returns the current Unix timestamp.&lt;br /&gt;&lt;br /&gt;Here's a simple script to demonstrate it. &lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;$t1 = time();&lt;br /&gt;&lt;br /&gt;print "Start time : ".$t1."&amp;lt;br&amp;gt;";&lt;br /&gt;&lt;br /&gt;for ($i = 0; $i &amp;lt; 90000000; $i++)&lt;br /&gt;    {&lt;br /&gt;    print "";&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;$t2 = time();&lt;br /&gt;print "End time : ".$t2."&amp;lt;br&amp;gt;";&lt;br /&gt;print "Time elapsed (s) : ".($t2 - $t1)."&amp;lt;br&amp;gt;";&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The script above will output the following.&lt;br /&gt;&lt;br /&gt;&lt;pre class="output"&gt;&lt;br /&gt;Start time : 1235100956&lt;br /&gt;End time : 1235100980&lt;br /&gt;Time elapsed (s) : 24&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-7896085066941806493?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/7896085066941806493/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=7896085066941806493" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/7896085066941806493?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/7896085066941806493?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/02/php-how-to-get-time-elaped.html" title="PHP: How to Get the Time Elaped" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;AkIGQHg9fSp7ImA9WxVXF0w.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-2078911606766500489</id><published>2009-02-15T11:50:00.005-05:00</published><updated>2009-02-15T12:22:01.665-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-15T12:22:01.665-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="blogging" /><title>Solved: Can't Change Blogger Blog Shortcut Icon</title><content type="html">Ok, you followed my instructions on &lt;a href="http://www.joelbadinas.com/2007/10/how-change-your-websites-shortcut-icon.html"&gt;how to change your blog/website shortcut icon&lt;/a&gt; but your Blogger blog is still showing the default &lt;a href="http://www.blogger.com/favicon.ico"&gt;Blogger shortcut logo&lt;/a&gt;. Don't despair, you are not alone. I myself was in that situation before when I tried to change this blog's shortcut icon.&lt;br /&gt;&lt;br /&gt;In your Blogger template &lt;code&gt;head&lt;/code&gt; tag section, you will see a &lt;code&gt;b:include&lt;/code&gt; tag named &lt;b&gt;all-head-content&lt;/b&gt; (highlighted in red) . When your is blog is visited (or loaded in HTML), the Blogger engine will replace that tag with all the &lt;code&gt;meta&lt;/code&gt; tags for you blog including the shortcut icon, and you have no control over this.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;head&amp;gt;&lt;br /&gt;  &lt;b style="color: rgb(255, 0, 0);"&gt;&amp;lt;b:include data='blog' name='all-head-content'/&amp;gt;&lt;/b&gt;&lt;br /&gt;  &amp;lt;title&amp;gt;&amp;lt;data:blog.pageTitle/&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;  &amp;lt;b:skin&amp;gt;&amp;lt;![CDATA[/*&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Fortunately, I found a simple trick to outsmart Blogger. When you insert your HTML &lt;a href="http://www.joelbadinas.com/2007/10/how-change-your-websites-shortcut-icon.html"&gt;shortcut icon code&lt;/a&gt;, put it after the &lt;code&gt;b:include&lt;/code&gt; tag named &lt;b&gt;all-head-content&lt;/b&gt;. Here's an example from this blog.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;head&amp;gt;&lt;br /&gt;  &amp;lt;b:include data='blog' name='all-head-content'/&amp;gt;&lt;br /&gt;  &amp;lt;title&amp;gt;&amp;lt;data:blog.pageTitle/&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;  &lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;&amp;lt;link href='http://kabalweg.googlepages.com/joelbadinas.com.ico' rel='shortcut icon'/&amp;gt;&lt;/span&gt;&lt;br /&gt;  &amp;lt;b:skin&amp;gt;&amp;lt;![CDATA[/*&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Doing it this way will override the shortcut icon from the Blogger enginge.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-2078911606766500489?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/2078911606766500489/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=2078911606766500489" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/2078911606766500489?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/2078911606766500489?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/02/solved-cant-change-blogger-blog.html" title="Solved: Can't Change Blogger Blog Shortcut Icon" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUMFQ38_fyp7ImA9WxVQE08.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-6824251433796165576</id><published>2009-01-30T08:34:00.003-05:00</published><updated>2009-01-30T08:50:12.147-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-30T08:50:12.147-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: How to Get the Last Element of an Array</title><content type="html">If you know it's length, getting the last element of an array is easy. You just put the index of the last element and you have it's value. But what if you don't know it's length or your array is populated at runtime and it's length is dynamic? Now you got a problem :).&lt;br /&gt;&lt;br /&gt;To solve this, you also need a dynamic approach. Using PHP's &lt;code&gt;&lt;a href="http://us.php.net/manual/en/function.count.php"&gt;count&lt;/a&gt;&lt;/code&gt; function, you can dynamically get the last element of an array. Here's how.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;//Getting the last element of an array dynamically&lt;br /&gt;&lt;br /&gt;$arr = array("one", "two", "three", "four", "five");&lt;br /&gt;print "Last element: " . $arr[&lt;b&gt;count&lt;/b&gt;($arr) -1];&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Take note that in PHP, arrays starts at 0, so if you have five elements, the index of the first element is 0 and the last's is 4. So the code &lt;code&gt;count($arr)&lt;/code&gt; will return 5, while &lt;code&gt;count($arr) - 1&lt;/code&gt; will return 4.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-6824251433796165576?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/6824251433796165576/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=6824251433796165576" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/6824251433796165576?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/6824251433796165576?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/php-how-to-get-last-element-of-array.html" title="PHP: How to Get the Last Element of an Array" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DEEGQXc6fCp7ImA9WxVQEk8.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-3272181943058871003</id><published>2009-01-29T05:57:00.000-05:00</published><updated>2009-01-29T05:57:00.914-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-29T05:57:00.914-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>Types of Loops in PHP</title><content type="html">A programming loop is a sequence of statements which is specified once but can also be performed several times in succession. Looping construct is one of the most powerful feature of all programming language. Using loops, you can duplicate task to any number of repetitions. &lt;br /&gt;&lt;br /&gt;If PHP, this are four types of looping construct, the &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;do...while&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;foreach&lt;/code&gt; loop. The following example demonstrates how to use each loop.&lt;br /&gt;&lt;br /&gt;Using the &lt;code&gt;while loop&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;$x=1;&lt;br /&gt;while($x&amp;lt;=10)&lt;br /&gt;  {&lt;br /&gt;  echo "The number is " . $x . "&amp;lt;br /&amp;gt;";&lt;br /&gt;  $x++;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;while loop&lt;/code&gt; output:&lt;br /&gt;&lt;br /&gt;&lt;pre class="output"&gt;The number is 1&lt;br /&gt;The number is 2&lt;br /&gt;The number is 3&lt;br /&gt;The number is 4&lt;br /&gt;The number is 5&lt;br /&gt;The number is 6&lt;br /&gt;The number is 7&lt;br /&gt;The number is 8&lt;br /&gt;The number is 9&lt;br /&gt;The number is 10&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Using the &lt;code&gt;do...while loop&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;$x=1;&lt;br /&gt;do&lt;br /&gt;  {&lt;br /&gt;  echo "The number is " . $x . "&amp;lt;br /&amp;gt;";&lt;br /&gt;  $x++;&lt;br /&gt;  }&lt;br /&gt;while ($x&amp;lt;10);&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;do...while loop&lt;/code&gt; output:&lt;br /&gt;&lt;br /&gt;&lt;pre class="output"&gt;The number is 1&lt;br /&gt;The number is 2&lt;br /&gt;The number is 3&lt;br /&gt;The number is 4&lt;br /&gt;The number is 5&lt;br /&gt;The number is 6&lt;br /&gt;The number is 7&lt;br /&gt;The number is 8&lt;br /&gt;The number is 9&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Using the &lt;code&gt;for loop&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;for ($x=1; $x&amp;lt;=10; $x++)&lt;br /&gt;  {&lt;br /&gt;  echo "The number is " . $x . "&amp;lt;br /&amp;gt;";&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;for loop&lt;/code&gt; output:&lt;br /&gt;&lt;br /&gt;&lt;pre class="output"&gt;The number is 1&lt;br /&gt;The number is 2&lt;br /&gt;The number is 3&lt;br /&gt;The number is 4&lt;br /&gt;The number is 5&lt;br /&gt;The number is 6&lt;br /&gt;The number is 7&lt;br /&gt;The number is 8&lt;br /&gt;The number is 9&lt;br /&gt;The number is 10&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Using the &lt;code&gt;foreach loop&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;$arr=array("one", "two", "three", "four", "five");&lt;br /&gt;foreach ($arr as $value)&lt;br /&gt;  {&lt;br /&gt;  echo "Value: " . $value . "&amp;lt;br /&amp;gt;";&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;foreach loop&lt;/code&gt; output:&lt;br /&gt;&lt;br /&gt;&lt;pre class="output"&gt;Value: one&lt;br /&gt;Value: two&lt;br /&gt;Value: three&lt;br /&gt;Value: four&lt;br /&gt;Value: five&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-3272181943058871003?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/3272181943058871003/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=3272181943058871003" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/3272181943058871003?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/3272181943058871003?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/types-of-loops-in-php.html" title="Types of Loops in PHP" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CE8NQns6fCp7ImA9WxVQEUk.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-1322131404452157937</id><published>2009-01-28T06:14:00.009-05:00</published><updated>2009-01-28T06:41:33.514-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-28T06:41:33.514-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: How to Parse XML Using the DOMDocument Class</title><content type="html">I this example, I will show you how to parse (or read) XML documents using PHP. I will be using the XML that I created in the &lt;a href="http://www.joelbadinas.com/2009/01/output-mysql-records-to-xml-using-php.html"&gt;Output MySQL Records to XML Using PHP&lt;/a&gt; post.&lt;br /&gt;&lt;br /&gt;To parse XML, I will be using PHP's&lt;a href="http://us.php.net/manual/en/class.domdocument.php"&gt; DOMDocument class&lt;/a&gt;. Here's the example.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;//CREATE AN INSTANCE OF DOMDocument() CLASS&lt;br /&gt;$doc = new DOMDocument();&lt;br /&gt;&lt;br /&gt;//LOAD THE XML&lt;br /&gt;$doc-&amp;gt;loadXML($xml);&lt;br /&gt;&lt;br /&gt;//READ THE &amp;lt;employee&amp;gt; AND LOOP THROUGH IT&lt;br /&gt;&lt;br /&gt;$employees = $doc-&amp;gt;getElementsByTagName("employee");&lt;br /&gt;foreach($employees as $employee)&lt;br /&gt;  {&lt;br /&gt;  //READ THE &amp;lt;firstname&amp;gt; AND GET THE NODE VALUE&lt;br /&gt;  $firstnames = $employee-&amp;gt;getElementsByTagName("firstname");&lt;br /&gt;  $firstname = $firstnames-&amp;gt;item(0)-&amp;gt;nodeValue; &lt;br /&gt;  &lt;br /&gt;  //READ THE &amp;lt;lastname&amp;gt; AND GET THE NODE VALUE&lt;br /&gt;  $lastnames = $employee-&amp;gt;getElementsByTagName("lastname");&lt;br /&gt;  $lastname = $lastnames-&amp;gt;item(0)-&amp;gt;nodeValue;   &lt;br /&gt;&lt;br /&gt;  //DISPLAY IT&lt;br /&gt;  print $firstname." ".$lastname."&amp;lt;br/&amp;gt;";&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The above source code will have the following output.&lt;br /&gt;&lt;br /&gt;&lt;pre class="output"&gt;Steven King&lt;br /&gt;Neena Kochhar&lt;br /&gt;Lex De Haan&lt;br /&gt;Alexander Hunold&lt;br /&gt;Bruce Ernst&lt;br /&gt;David Austin&lt;br /&gt;Valli Pataballa&lt;br /&gt;Diana Lorentz&lt;br /&gt;Nancy Greenberg&lt;br /&gt;Daniel Faviet&lt;br /&gt;John Chen&lt;br /&gt;Ismael Sciarra&lt;br /&gt;Jose Manuel Urman&lt;br /&gt;Luis Popp&lt;br /&gt;Den Raphaely&lt;br /&gt;Alexander Khoo&lt;br /&gt;Shelli Baida&lt;br /&gt;Sigal Tobias&lt;br /&gt;Guy Himuro&lt;br /&gt;Karen Colmenares&lt;br /&gt;Matthew Weiss&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you want to parse an physical XML file (an XML file that is saved in your server), use &lt;code&gt;&lt;a href="http://us.php.net/manual/en/domdocument.load.php"&gt;load&lt;/a&gt;&lt;/code&gt; rather than &lt;code&gt;&lt;a href="http://us.php.net/manual/en/domdocument.loadxml.php"&gt;loadXML&lt;/a&gt;&lt;/code&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-1322131404452157937?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/1322131404452157937/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=1322131404452157937" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/1322131404452157937?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/1322131404452157937?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/php-how-to-parse-xml.html" title="PHP: How to Parse XML Using the DOMDocument Class" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;CE4HRng7fyp7ImA9WxVQEUk.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-2846017769768225372</id><published>2009-01-27T08:57:00.009-05:00</published><updated>2009-01-28T06:42:17.607-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-28T06:42:17.607-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mysql" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: How to Create XML Document from MySQL Records</title><content type="html">In this example, I'll be showing how to create XML document from MySQL records using PHP.&lt;br /&gt;&lt;br /&gt;XML (Extensible Markup Language) is a general-purpose specification for creating custom markup languages. Aside from creating web pages, the most important use of XML is data sharing. Using XML you can pass data to different computer and applications without it being converted into another form.&lt;br /&gt;&lt;br /&gt;Fortunately for PHP developers, creating XML from MySQL data is just like creating HTML. I'll be using the database table from this &lt;a href="http://www.joelbadinas.com/2009/01/sql-how-to-copy-database-table.html"&gt;post&lt;/a&gt;. Here's the source codes.  &lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;//CREATE A DATABASE CONNECTION&lt;br /&gt;$db_conn = mysql_connect("localhost", "root", "root1") &lt;br /&gt;           or die("Cannot connect to the database. ".mysql_error()); &lt;br /&gt;//SELECT THE DATABASE TO USE&lt;br /&gt;mysql_select_db("test");&lt;br /&gt;&lt;br /&gt;$sql = "SELECT&lt;br /&gt;           first_name, last_name, email&lt;br /&gt;        FROM employees";&lt;br /&gt;&lt;br /&gt;$result = mysql_query($sql, $db_conn);&lt;br /&gt;&lt;br /&gt;$xml = "&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&lt;br /&gt; &amp;lt;employees&amp;gt;";&lt;br /&gt;while ($row = mysql_fetch_assoc($result))&lt;br /&gt;    {&lt;br /&gt; $xml .= "&amp;lt;employee&amp;gt;";&lt;br /&gt; $xml .= "&amp;lt;firstname&amp;gt;".$row["first_name"]."&amp;lt;/firstname&amp;gt;";&lt;br /&gt; $xml .= "&amp;lt;lastname&amp;gt;".$row["last_name"]."&amp;lt;/lastname&amp;gt;";&lt;br /&gt; $xml .= "&amp;lt;/employee&amp;gt;";&lt;br /&gt;    }&lt;br /&gt;$xml .= "&amp;lt;/employees&amp;gt;";&lt;br /&gt;&lt;br /&gt;//DISPLAY THE XML&lt;br /&gt;print $xml;&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This will output the following. I added line breaks (using enter key) at the end of every &amp;lt;/employee&amp;gt; tags to make it more readable.&lt;br /&gt;&lt;br /&gt;&lt;pre class="output"&gt;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&lt;br /&gt;&amp;lt;employees&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Steven&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;King&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Neena&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Kochhar&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Lex&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;De Haan&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Alexander&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Hunold&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Bruce&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Ernst&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;David&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Austin&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Valli&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Pataballa&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Diana&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Lorentz&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Nancy&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Greenberg&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Daniel&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Faviet&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;John&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Chen&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Ismael&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Sciarra&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Jose Manuel&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Urman&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Luis&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Popp&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Den&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Raphaely&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Alexander&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Khoo&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Shelli&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Baida&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Sigal&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Tobias&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Guy&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Himuro&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Karen&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Colmenares&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;employee&amp;gt;&amp;lt;firstname&amp;gt;Matthew&amp;lt;/firstname&amp;gt;&amp;lt;lastname&amp;gt;Weiss&amp;lt;/lastname&amp;gt;&amp;lt;/employee&amp;gt;&lt;br /&gt;&amp;lt;/employees&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note: To view the full output, right click on the browser and select 'View Source' or 'View Page Source'.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-2846017769768225372?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/2846017769768225372/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=2846017769768225372" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/2846017769768225372?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/2846017769768225372?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/output-mysql-records-to-xml-using-php.html" title="PHP: How to Create XML Document from MySQL Records" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkAESH0_eyp7ImA9WxVRGUo.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-6841613715916309360</id><published>2009-01-26T08:22:00.000-05:00</published><updated>2009-01-26T09:05:09.343-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-26T09:05:09.343-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: How to Print Each Character in a String</title><content type="html">With PHP's growing string functions, you will be able to find one that will suit your need. For instance the &lt;code&gt;substr&lt;/code&gt;, this function will return the portion of string  specified by the start  and length  parameters. You can you use it to print each character in a string.&lt;br /&gt;&lt;br /&gt;Here's an example.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&lt;?php&lt;br /&gt;    &lt;br /&gt;$string = "Joel P. Badinas";&lt;br /&gt;&lt;br /&gt;for ($i = 0; $i &lt; strlen($string); $i++)&lt;br /&gt;    {&lt;br /&gt;    print "[" . $i . "] " . substr($string, $i, 1) ."&amp;lt;br/&amp;gt;";    &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;?&gt; &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The output will be like this.&lt;br /&gt;&lt;br /&gt;&lt;pre class='output'&gt;  [0]  J&lt;br /&gt;  [1]  o&lt;br /&gt;  [2]  e&lt;br /&gt;  [3]  l&lt;br /&gt;  [4]  &lt;br /&gt;  [5]  P&lt;br /&gt;  [6]  .&lt;br /&gt;  [7]  &lt;br /&gt;  [8]  B&lt;br /&gt;  [9]  a&lt;br /&gt;  [10]  d&lt;br /&gt;  [11]  i&lt;br /&gt;  [12]  n&lt;br /&gt;  [13]  a&lt;br /&gt;  [14]  s&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-6841613715916309360?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/6841613715916309360/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=6841613715916309360" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/6841613715916309360?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/6841613715916309360?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/php-how-to-print-each-character-in.html" title="PHP: How to Print Each Character in a String" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;CkYBR3YzeSp7ImA9WxVRGU8.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-2067703686174106870</id><published>2009-01-25T15:59:00.000-05:00</published><updated>2009-01-25T16:49:16.881-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-25T16:49:16.881-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mysql" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>Database Insert, Update and Delete Using PHP and MySQL</title><content type="html">One of the best uses of PHP to the MySQL database is data manipulation. PHP's native support to MySQL is a big advantage to developers who uses the two. Once you got PHP and MySQL running in your server, you're good to go toward dynamic web application. &lt;br /&gt;&lt;br /&gt;In the following examples, I'll be focusing on how to do data &lt;b&gt;INSERT&lt;/b&gt;, &lt;b&gt;UPDATE&lt;/b&gt;, and &lt;b&gt;DELETE&lt;/b&gt; to the database using the web's two powerful combination, PHP and MySQL. &lt;br /&gt;&lt;br /&gt;Here's the first one, doing data &lt;b&gt;INSERT&lt;/b&gt; to the database. In these examples, I use the table from this &lt;a href="http://www.joelbadinas.com/2009/01/sql-how-to-copy-database-table.html"&gt;post&lt;/a&gt; which I created in the &lt;b&gt;test&lt;/b&gt; database in MySQL.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;//CREATE A DATABASE CONNECTION&lt;br /&gt;$db_conn = mysql_connect("localhost", "root", "root1") &lt;br /&gt;           or die("Cannot connect to the database. ".mysql_error());  &lt;br /&gt;//SELECT THE DATABASE TO USE&lt;br /&gt;mysql_select_db("test");&lt;br /&gt;&lt;br /&gt;//COMPOSE THE SQL&lt;br /&gt;$sql = "INSERT INTO employees (&lt;br /&gt;    first_name, &lt;br /&gt;    last_name, &lt;br /&gt;    email,&lt;br /&gt;    phone_number)&lt;br /&gt;  VALUES (&lt;br /&gt;    'Joel',&lt;br /&gt;    'Badinas',&lt;br /&gt;    'kabalweg@gmail.com',&lt;br /&gt;    '123.456.7890')";&lt;br /&gt;    &lt;br /&gt;//EXECUTE SQL&lt;br /&gt;$result = mysql_query($sql, $db_conn);&lt;br /&gt;&lt;br /&gt;//CHECK IF QUERY IS SUCCESSFUL&lt;br /&gt;if(mysql_affected_rows($db_conn) &gt; 0)&lt;br /&gt;  {&lt;br /&gt;  print "Save successful";&lt;br /&gt;  }&lt;br /&gt;else&lt;br /&gt;  {&lt;br /&gt;  print "Error: ".mysql_error();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And here's how to do the data &lt;b&gt;Update&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;//CREATE A DATABASE CONNECTION&lt;br /&gt;$db_conn = mysql_connect("localhost", "root", "root1") &lt;br /&gt;           or die("Cannot connect to the database. ".mysql_error());  &lt;br /&gt;//SELECT THE DATABASE TO USE&lt;br /&gt;mysql_select_db("test");&lt;br /&gt;&lt;br /&gt;//COMPOSE THE SQL&lt;br /&gt;$sql = "UPDATE employees SET &lt;br /&gt;    first_name = 'Kabalweg' &lt;br /&gt;  WHERE first_name = 'Joel' &lt;br /&gt;  AND   last_name = 'Badinas'";&lt;br /&gt;&lt;br /&gt;//EXECUTE SQL&lt;br /&gt;$result = mysql_query($sql, $db_conn);&lt;br /&gt;&lt;br /&gt;//CHECK IF QUERY IS SUCCESSFUL&lt;br /&gt;if(mysql_affected_rows($db_conn) &gt; 0)&lt;br /&gt;  {&lt;br /&gt;  print "Update successful";&lt;br /&gt;  }&lt;br /&gt;else&lt;br /&gt;  {&lt;br /&gt;  print "Error: ".mysql_error();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And the last is the &lt;b&gt;DELETE&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;//CREATE A DATABASE CONNECTION&lt;br /&gt;$db_conn = mysql_connect("localhost", "root", "root1") &lt;br /&gt;           or die("Cannot connect to the database. ".mysql_error());  &lt;br /&gt;//SELECT THE DATABASE TO USE&lt;br /&gt;mysql_select_db("test");&lt;br /&gt;&lt;br /&gt;//COMPOSE THE SQL&lt;br /&gt;$sql = "DELETE FROM employees &lt;br /&gt;  WHERE first_name = 'Kabalweg' &lt;br /&gt;  AND   last_name = 'Badinas'";&lt;br /&gt;&lt;br /&gt;//EXECUTE SQL&lt;br /&gt;$result = mysql_query($sql, $db_conn);&lt;br /&gt;&lt;br /&gt;//CHECK IF QUERY IS SUCCESSFUL&lt;br /&gt;if(mysql_affected_rows($db_conn) &gt; 0)&lt;br /&gt;  {&lt;br /&gt;  print "Delete successful";&lt;br /&gt;  }&lt;br /&gt;else&lt;br /&gt;  {&lt;br /&gt;  print "Error: ".mysql_error();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;There you have it. The source codes are well commented so you should be able to follow. If not, post a question in the comment.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-2067703686174106870?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/2067703686174106870/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=2067703686174106870" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/2067703686174106870?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/2067703686174106870?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/database-insert-update-and-delete-using.html" title="Database Insert, Update and Delete Using PHP and MySQL" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;D0UDSH49fip7ImA9WxVRGE0.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-891624045723187156</id><published>2009-01-24T08:34:00.004-05:00</published><updated>2009-01-24T08:54:39.066-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-24T08:54:39.066-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="html" /><title>How to Redirect a Web Page Using HTML</title><content type="html">How to redirect a web page using HTML is just easy as &lt;a href="http://www.joelbadinas.com/2008/02/how-to-redirect-to-another-website-in.html"&gt;redirect in PHP&lt;/a&gt;. While in PHP we use the &lt;code&gt;header&lt;/code&gt; function, in HTML, we use the &lt;code&gt;meta&lt;/code&gt; tag to accomplish the same task.&lt;br /&gt;&lt;br /&gt;Here's an example.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;  &amp;lt;head&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;HTML Redirect in Meta Tag&amp;lt;/title&amp;gt;&lt;br /&gt;    &lt;b&gt;&amp;lt;meta http-equiv="REFRESH" content="0;url=http://localhost/redirect.php"&amp;gt;&lt;/b&gt;&lt;br /&gt;  &amp;lt;/head&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;body&amp;gt;&lt;br /&gt;  &lt;br /&gt;  &amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In HTML redirection, the &lt;b&gt;content&lt;/b&gt; attribute of the &lt;code&gt;meta&lt;/code&gt; tag should contain the number of seconds to pause before doing the redirection and the page where to redirect. The above sourcecode will redirect the current page to &lt;i&gt;http://localhost/redirect.php&lt;/i&gt; in 0 second.&lt;br /&gt;&lt;br /&gt;If you want to notify your visitor before redirecting, you can specify the number of seconds to pause. This way, you can display a message in your current page. &lt;br /&gt;&lt;br /&gt;Here's how.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;  &amp;lt;head&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;HTML Redirect in Meta Tag&amp;lt;/title&amp;gt;&lt;br /&gt;    &lt;b&gt;&amp;lt;meta http-equiv="REFRESH" content="5;url=http://localhost/redirect.php"&amp;gt;&lt;/b&gt;&lt;br /&gt;  &amp;lt;/head&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;body&amp;gt;&lt;br /&gt;    &lt;br /&gt;    &amp;lt;p&amp;gt;This page will redirect in 5 seconds...&amp;lt;/p&amp;gt;&lt;br /&gt;  &lt;br /&gt;  &amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-891624045723187156?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/891624045723187156/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=891624045723187156" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/891624045723187156?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/891624045723187156?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/how-to-redirect-using-html.html" title="How to Redirect a Web Page Using HTML" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A0ICRHs6eCp7ImA9WxVRFkU.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-5186966938054694699</id><published>2009-01-23T00:32:00.005-05:00</published><updated>2009-01-23T00:46:05.510-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-23T00:46:05.510-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="html" /><title>How to Submit an HTML Form to a New Window</title><content type="html">Sometimes, for whatever reason, you want to submit an HTML form to a new window. To do this, you just need to add the attribute &lt;code&gt;target='_blank'&lt;/code&gt; to your HTML form. Here's an example.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;form &lt;b&gt;target='_blank'&lt;/b&gt; method='POST' action='index.php'&amp;gt;&lt;br /&gt;   &amp;lt;br/&amp;gt;First Name: &amp;lt;input type='text' name='firstname' value='' /&amp;gt;&lt;br /&gt;   &amp;lt;br/&amp;gt;Last Name: &amp;lt;input type='text' name='lastname' value='' /&amp;gt;&lt;br /&gt;   &amp;lt;br/&amp;gt;&amp;lt;input type='submit' name='submit' value='Submit' /&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And here's the PHP version.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;print "&amp;lt;form &lt;b&gt;target='_blank'&lt;/b&gt; method='POST' action='index.php'&amp;gt;&lt;br /&gt;         &amp;lt;br/&amp;gt;First Name: &amp;lt;input type='text' name='firstname' value='' /&amp;gt;&lt;br /&gt;         &amp;lt;br/&amp;gt;Last Name: &amp;lt;input type='text' name='lastname' value='' /&amp;gt;&lt;br /&gt;         &amp;lt;br/&amp;gt;&amp;lt;input type='submit' name='submit' value='Submit' /&amp;gt;&lt;br /&gt;       &amp;lt;/form&amp;gt;";&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Once you click the Submit button, the browser will submit and open a new window where the &lt;code&gt;form&lt;/code&gt; will be handled.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-5186966938054694699?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/5186966938054694699/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=5186966938054694699" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/5186966938054694699?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/5186966938054694699?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/how-to-submit-html-form-to-new-window.html" title="How to Submit an HTML Form to a New Window" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DUIERn47eCp7ImA9WxVRFkU.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-1973333937805926240</id><published>2009-01-22T08:29:00.004-05:00</published><updated>2009-01-23T00:11:47.000-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-23T00:11:47.000-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: Using foreach to Loop Through Array</title><content type="html">The &lt;code&gt;foreach&lt;/code&gt; looping construct in one of the less used looping construnct in the programming language, and PHP is not an exception. This is because in PHP, the &lt;code&gt;foreach&lt;/code&gt; works only with arrays and will spit an error if used with other data type.&lt;br /&gt;&lt;br /&gt;Anyways, using the &lt;code&gt;foreach&lt;/code&gt; loop construct is really easy. See example below.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;$array = array("j", "o", "e", "l", "b", "a", "d", "i", "n", "a", "s");&lt;br /&gt;&lt;br /&gt;foreach ($array as $char)&lt;br /&gt;    {&lt;br /&gt;    print $char."&amp;lt;br/&amp;gt;";&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The above example will output below.&lt;br /&gt;&lt;br /&gt;&lt;pre class="output"&gt;j&lt;br /&gt;o&lt;br /&gt;e&lt;br /&gt;l&lt;br /&gt;b&lt;br /&gt;a&lt;br /&gt;d&lt;br /&gt;i&lt;br /&gt;n&lt;br /&gt;a&lt;br /&gt;s&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-1973333937805926240?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/1973333937805926240/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=1973333937805926240" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/1973333937805926240?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/1973333937805926240?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/php-using-foreach-loop.html" title="PHP: Using foreach to Loop Through Array" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkUCSX4-fyp7ImA9WxVRFUk.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-1291425801408863439</id><published>2009-01-21T07:51:00.004-05:00</published><updated>2009-01-21T08:24:28.057-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-21T08:24:28.057-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>How to Truncate Text in PHP</title><content type="html">Here's a simple tutorial on how to truncate text in PHP. In this tutorial, I'll be using the &lt;code&gt;substr&lt;/code&gt; function. See the sourcecode below.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;$text = 'The quick brown fox jumps over the lazy dog';&lt;br /&gt;$truncated1 = substr($text, 0, 20);&lt;br /&gt;$truncated2 = substr($text, 20, 40);&lt;br /&gt;&lt;br /&gt;print "&amp;lt;br/&amp;gt;The original text: ". $text;&lt;br /&gt;print "&amp;lt;br/&amp;gt;The truncated text 1: ". $truncated1;&lt;br /&gt;print "&amp;lt;br/&amp;gt;The truncated text 2: ". $truncated2;&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Using the &lt;code&gt;substr&lt;/code&gt; function, you can truncate a text to whatever length you want by changing the third parameter and also change the start position by changing the second parameter.&lt;br /&gt;&lt;br /&gt;The above PHP script will output the following:&lt;br /&gt;&lt;br /&gt;&lt;pre class="output"&gt;The original text: The quick brown fox jumps over the lazy dog&lt;br /&gt;The truncated text 1: The quick brown fox&lt;br /&gt;The truncated text 2: jumps over the lazy dog&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-1291425801408863439?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/1291425801408863439/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=1291425801408863439" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/1291425801408863439?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/1291425801408863439?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/how-to-truncate-text-in-php.html" title="How to Truncate Text in PHP" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DkQEQHk5fCp7ImA9WxVRFUk.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-5749466364459220582</id><published>2009-01-16T08:38:00.006-05:00</published><updated>2009-01-21T08:25:01.724-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-21T08:25:01.724-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ajax" /><category scheme="http://www.blogger.com/atom/ns#" term="tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>Simple PHP and Ajax Tutorial</title><content type="html">When I was beginning web development, Ajax was all blur to me. Whenever I need Ajax functionality for my PHP project, I would go to the web and search to similar Ajax examples that fit need. Although today I'm not yet a master of this WEB 2.0 technique, I can say I passed the beginner stage.&lt;br /&gt;&lt;br /&gt;In PHP, a simple, yet powerful implementation of Ajax is querying and displaying the result of a database query. This makes your web application run faster than just pure PHP because the browser don't have to load.&lt;br /&gt;&lt;br /&gt;This simple PHP and Ajax tutorial is composed of three files, namely, &lt;b&gt;index.php, ajax.js and ajax.php&lt;/b&gt;. I will be using the database from this &lt;a href="http://www.joelbadinas.com/2009/01/sql-how-to-copy-database-table.html"&gt;post&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Here's the index.php. This file contains the HTML codes and the container in which the result of the query will be displayed.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;A Simple PHP-Ajax Tutotial&amp;lt;/title&amp;gt;&lt;br /&gt;    &amp;lt;script src="ajax.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;br/&amp;gt;&amp;lt;input type='button' value='Query' onclick='queryDb()' name='Query' /&amp;gt;&amp;lt;br/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;div id='container'&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;ajax.js&lt;/b&gt; file contains the Javascript code.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;//CREATE A VARIABLE THAT WILL HOLD THE XMLHttpRequest OBJECT&lt;br /&gt;request = null;&lt;br /&gt;&lt;br /&gt;//THIS FUNCTION WILL CREATE AN INSTANCE OF XMLHttpRequest OBJECT &lt;br /&gt;AND RETURN IT TO THE CALLING FUNCTION&lt;br /&gt;function GetXmlHttpObject()&lt;br /&gt;    {&lt;br /&gt;    var xmlHttp=null;&lt;br /&gt;    try&lt;br /&gt;        {&lt;br /&gt;        // Firefox, Opera 8.0+, Safari&lt;br /&gt;        xmlHttp=new XMLHttpRequest();&lt;br /&gt;         }&lt;br /&gt;    catch (e)&lt;br /&gt;         {&lt;br /&gt;         //Internet Explorer&lt;br /&gt;         try&lt;br /&gt;              {&lt;br /&gt;              xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");&lt;br /&gt;              }&lt;br /&gt;         catch (e)&lt;br /&gt;              {&lt;br /&gt;              xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");&lt;br /&gt;              }&lt;br /&gt;         }&lt;br /&gt;    return xmlHttp;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;//THIS FUNCTION WILL CALL THE GetXmlHttpObject() FUNCTION AND THE ajax.php PAGE&lt;br /&gt;function queryDb()&lt;br /&gt;    {&lt;br /&gt;    //DISPLAY THE 'LOADING' TEXT IN THE DIV CONTAINER&lt;br /&gt;    document.getElementById("container").innerHTML = "Loading";&lt;br /&gt;    //CREATE AN INSTANCE OF XMLHttpRequest OBJECT&lt;br /&gt;    request = GetXmlHttpObject();&lt;br /&gt;    //SET queryDone FUNCTION TO THE onreadystatechange EVENT&lt;br /&gt;    request.onreadystatechange = queryDone;&lt;br /&gt;    //OPEN THE PHP PAGE USING THE POST METHOD&lt;br /&gt;    request.open("POST", "ajax.php", true);&lt;br /&gt;    //SEND THE REQUEST&lt;br /&gt;    request.send(null);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;//HELPER FUNCTION FOR queryDb()&lt;br /&gt;function queryDone()&lt;br /&gt;    {&lt;br /&gt;    if (request.readyState == 4)&lt;br /&gt;        {&lt;br /&gt;        if (request.status == 200 || request.status == 304)&lt;br /&gt;            {&lt;br /&gt;            //GET THE RESPONSE FROM THE PHP PAGE&lt;br /&gt;            results = request.responseText;&lt;br /&gt;            //DISPLAY THE RESPONSE IN THE DIV CONTAINER&lt;br /&gt;            document.getElementById("container").innerHTML = results;&lt;br /&gt;            }&lt;br /&gt;        else&lt;br /&gt;            {&lt;br /&gt;            //IF A ERROR OCCUR, DISPLAY IT IN THE DIV CONTAINER&lt;br /&gt;            document.getElementById("container").innerHTML = "ajax error:\n" + request.statusText;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;ajax.php&lt;/b&gt; file contains the PHP code that will connect and query the database. It will display the result of the query using the &lt;code&gt;print&lt;/code&gt; function, which will in turn will be passed by the Javascript code to the HTML container. &lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;//CONNECT TO MYSQL DATABASE&lt;br /&gt;$con = mysql_connect("localhost", "root", "root1") &lt;br /&gt;       or die("&amp;lt;p class='error-msg'&amp;gt;Cannot connect to the database. ".mysql_error()."&amp;lt;/p&amp;gt;");            &lt;br /&gt;&lt;br /&gt;//SELECT A DATABASE&lt;br /&gt;mysql_select_db("test");&lt;br /&gt;&lt;br /&gt;//COMPOSE QUERY&lt;br /&gt;$sql = "&lt;br /&gt;          SELECT&lt;br /&gt;           CONCAT(first_name, ' ', last_name) AS name&lt;br /&gt;          FROM employees&lt;br /&gt;          LIMIT 0, 10";&lt;br /&gt;&lt;br /&gt;//print "&amp;lt;pre&amp;gt;".$sql."&amp;lt;/pre&amp;gt;";&lt;br /&gt;            &lt;br /&gt;//EXECUTE THE QUERY&lt;br /&gt;$result = mysql_query($sql, $con);&lt;br /&gt;&lt;br /&gt;while ($row = mysql_fetch_assoc($result))&lt;br /&gt;    {&lt;br /&gt;    print "&amp;lt;br/&amp;gt;".$row["name"];&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;To run this example, copy and paste the sourcecodes above, name it &lt;b&gt;index.php, ajax.js and ajax.php&lt;/b&gt; respectively and save it in the same folder of your server.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-5749466364459220582?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/5749466364459220582/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=5749466364459220582" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/5749466364459220582?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/5749466364459220582?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/simple-php-and-ajax-tutorial.html" title="Simple PHP and Ajax Tutorial" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEMDRHg_cCp7ImA9WxVREE8.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-2092593551676638664</id><published>2009-01-15T07:10:00.003-05:00</published><updated>2009-01-15T07:27:55.648-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-15T07:27:55.648-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: How to Delete the First and Last Character in a String</title><content type="html">Using PHP's &lt;code&gt;substr&lt;/code&gt; and &lt;code&gt;strlen&lt;/code&gt; functions, you can delete the first and last character in a string. Here's the syntax of the functions from the &lt;a href="http://us3.php.net/manual/en"&gt;PHP documentation&lt;/a&gt; website.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;string substr  ( string $string  , int $start  [, int $length  ] )&lt;br /&gt;&lt;br /&gt;int strlen  ( string $string  )&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;substr&lt;/code&gt; returns a part of a string, while &lt;code&gt;strlen&lt;/code&gt; returns the length of a string. See below for the example.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;$my_name = "Joel Badinas";&lt;br /&gt;$str_length = strlen($my_name);&lt;br /&gt;&lt;br /&gt;$no_first_char = substr($my_name, 1, $str_length);&lt;br /&gt;$no_last_char = substr($my_name, 0, $str_lenght - 1);&lt;br /&gt;&lt;br /&gt;print ("Original String       : " . $my_name . "&amp;lt;br/&amp;gt;");&lt;br /&gt;print ("No first character: " . $no_first_char . "&amp;lt;br/&amp;gt;");&lt;br /&gt;print ("No last character: " . $no_last_char . "&amp;lt;br/&amp;gt;");&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The above source code will display the following:&lt;br /&gt;&lt;br /&gt;&lt;pre class="output"&gt;Original String : Joel Badinas&lt;br /&gt;No first character: oel Badinas&lt;br /&gt;No last character: Joel Badina&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-2092593551676638664?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/2092593551676638664/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=2092593551676638664" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/2092593551676638664?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/2092593551676638664?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/php-how-to-delete-first-and-last.html" title="PHP: How to Delete the First and Last Character in a String" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DU4GSXw7fip7ImA9WxVSGEw.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-7122674979328626555</id><published>2009-01-12T21:30:00.003-05:00</published><updated>2009-01-12T22:38:48.206-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-12T22:38:48.206-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mysql" /><category scheme="http://www.blogger.com/atom/ns#" term="tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP and MySQL Search/Browse Pagination Tutorial</title><content type="html">Pagination in a website is very useful, especially in a search or browse page. In fact, almost all website with search pages utilize this technique. And no other websites other than search engines benefit from this. Here's simple implementation of &lt;a href="http://google.com"&gt;Google&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_HWU3wX2cDLQ/SWwCbM_vqQI/AAAAAAAAE-o/rhITLczBgIE/s1600-h/google_pagination.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 250px;" src="http://2.bp.blogspot.com/_HWU3wX2cDLQ/SWwCbM_vqQI/AAAAAAAAE-o/rhITLczBgIE/s400/google_pagination.jpg" border="0" alt="google pagination" id="BLOGGER_PHOTO_ID_5290606328621803778" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;That being said, it's time you add this feature to you blog or website. Fortunately for us, search and browse pagination in PHP and MySQL in fairly easy, thanks to MySQL's &lt;code&gt;LIMIT&lt;/code&gt; keyword that you can use in &lt;code&gt;SELET&lt;/code&gt; queries.&lt;br /&gt;&lt;br /&gt;In this tutorial, I'm going to use the database from this &lt;a href="http://www.joelbadinas.com/2009/01/sql-how-to-copy-database-table.html"&gt;post&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Start by setting the size or the number of rows of each page.&lt;br /&gt;&lt;pre class="sourcecodes"&gt;$page_size = 10;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Connect to the database and select the database to use.&lt;br /&gt;&lt;pre class="sourcecodes"&gt;$con = mysql_connect("localhost", "root", "root1") &lt;br /&gt;  or die("Cannot connect to the database. ".mysql_error().");           &lt;br /&gt;&lt;br /&gt;mysql_select_db("test");&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Using MySQL's &lt;code&gt;CEILING&lt;/code&gt; function, count the number of pages by dividing the rows with the &lt;code&gt;$page_size&lt;/code&gt; variable we declared earlier. &lt;br /&gt;&lt;pre class="sourcecodes"&gt;//COMPOSE QUERY&lt;br /&gt;$sql = "SELECT&lt;br /&gt;          CEILING(count(1) / ".$page_size.") AS count&lt;br /&gt;        FROM employees";&lt;br /&gt;&lt;br /&gt;$result = mysql_query($sql, $con);&lt;br /&gt;&lt;br /&gt;if ($row = mysql_fetch_assoc($result))&lt;br /&gt;    {&lt;br /&gt;    $page_count = $row["count"];&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Using the HTML &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag, display the number of pages.&lt;br /&gt;&lt;pre class="sourcecodes"&gt;for ($i = 1; $i &lt; $page_count + 1; $i++)&lt;br /&gt;    {&lt;br /&gt;    print "&amp;lt;a href='?page=".$i."'&amp;gt;".$i."&amp;lt;/a&amp;gt;&amp;nbsp;&amp;nbsp;";&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Check if the &lt;code&gt;GET&lt;/code&gt; variable, page, is available and set the $limit variable.&lt;br /&gt;&lt;pre class="sourcecodes"&gt;if (isset($_GET["page"]))   &lt;br /&gt;    {&lt;br /&gt;    $page_no = $_GET["page"];&lt;br /&gt;    $limit =  ($page_no * $page_size) - $page_size;&lt;br /&gt;    }&lt;br /&gt;else&lt;br /&gt;    {&lt;br /&gt;    $limit =  0;&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Compose and execute the query and display the result.&lt;br /&gt;&lt;pre class="sourcecodes"&gt;$sql = "SELECT&lt;br /&gt;           CONCAT(first_name, ' ', last_name) AS name&lt;br /&gt;        FROM employees&lt;br /&gt;        LIMIT ".$limit .", ".$page_size;&lt;br /&gt;&lt;br /&gt;          &lt;br /&gt;$result = mysql_query($sql, $con);&lt;br /&gt;&lt;br /&gt;print "&amp;lt;br/&amp;gt;";&lt;br /&gt;while ($row = mysql_fetch_assoc($result))&lt;br /&gt;    {&lt;br /&gt;    print "&amp;lt;br/&amp;gt;".$row["name"];&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here's the complete code.&lt;br /&gt;&lt;pre class="sourcecodes"&gt;//SET THE ROWS FOR EVERY PAGE&lt;br /&gt;$page_size = 10;&lt;br /&gt;   &lt;br /&gt;//CONNECT TO MYSQL DATABASE&lt;br /&gt;$con = mysql_connect("localhost", "root", "crop") &lt;br /&gt;  or die("&amp;lt;p class='error-msg'&amp;gt;Cannot connect to the database. ".mysql_error()."&amp;lt;/p&amp;gt;");           &lt;br /&gt;&lt;br /&gt;//SELECT A DATABASE&lt;br /&gt;mysql_select_db("test");&lt;br /&gt;&lt;br /&gt;//COMPOSE QUERY&lt;br /&gt;$sql = "SELECT&lt;br /&gt;             CEILING(count(1) / ".$page_size.") AS count&lt;br /&gt;            FROM employees";&lt;br /&gt;&lt;br /&gt;//EXECUTE THE QUERY&lt;br /&gt;$result = mysql_query($sql, $con);&lt;br /&gt;&lt;br /&gt;if ($row = mysql_fetch_assoc($result))&lt;br /&gt;    {&lt;br /&gt;    $page_count = $row["count"];&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;//DISPLAY A LINK TO THE NUMBER OF PAGES&lt;br /&gt;for ($i = 1; $i &amp;lt; $page_count + 1; $i++)&lt;br /&gt;    {&lt;br /&gt;    print "&amp;lt;a href='?page=".$i."'&amp;gt;".$i."&amp;lt;/a&amp;gt;&amp;nbsp;&amp;nbsp;";&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;//CHECK IF PAGE VARIABLE IS AVAILABLE AND CALCULATE THE LIMIT&lt;br /&gt;if (isset($_GET["page"]))   &lt;br /&gt;    {&lt;br /&gt;    $page_no = $_GET["page"];&lt;br /&gt;    $limit =  ($page_no * $page_size) - $page_size;&lt;br /&gt;    }&lt;br /&gt;else&lt;br /&gt;    {&lt;br /&gt;    $limit =  0;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;//COMPOSE QUERY&lt;br /&gt;$sql = "SELECT&lt;br /&gt;           CONCAT(first_name, ' ', last_name) AS name&lt;br /&gt;        FROM employees&lt;br /&gt;        LIMIT ".$limit .", ".$page_size;&lt;br /&gt;&lt;br /&gt;          &lt;br /&gt;//EXECUTE THE QUERY&lt;br /&gt;$result = mysql_query($sql, $con);&lt;br /&gt;&lt;br /&gt;print "&amp;lt;br/&amp;gt;";&lt;br /&gt;while ($row = mysql_fetch_assoc($result))&lt;br /&gt;    {&lt;br /&gt;    print "&amp;lt;br/&amp;gt;".$row["name"];&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you follow my example above, you should be able to see the result like this.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_HWU3wX2cDLQ/SWwMW-JvqoI/AAAAAAAAE-w/YCkjqIhJGUQ/s1600-h/pagination_result.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 320px;" src="http://1.bp.blogspot.com/_HWU3wX2cDLQ/SWwMW-JvqoI/AAAAAAAAE-w/YCkjqIhJGUQ/s400/pagination_result.jpg" border="0" alt="pagination result" id="BLOGGER_PHOTO_ID_5290617251034016386" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-7122674979328626555?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/7122674979328626555/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=7122674979328626555" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/7122674979328626555?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/7122674979328626555?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/php-and-mysql-searchbrowse-pagination.html" title="PHP and MySQL Search/Browse Pagination Tutorial" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_HWU3wX2cDLQ/SWwCbM_vqQI/AAAAAAAAE-o/rhITLczBgIE/s72-c/google_pagination.jpg" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUEBQXo7eSp7ImA9WxVSE0U.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-1301156330712256539</id><published>2009-01-07T21:25:00.006-05:00</published><updated>2009-01-07T22:00:50.401-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-07T22:00:50.401-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL" /><title>SQL: How to Copy the Database Table Definition and Data Using SQL Scripts</title><content type="html">Here are simple, yet powerful SQL scripts to copy the entire definition and data of a database table. These SQL scripts are useful if you are making a backup of a table without a GUI. The only drawback of using these, is that it doesn't copy the keys and constraints of the table. But personally, I prefer using these scripts when I make a backup than using a GUI because it's so simple and I get to practice my SQL :). See below.&lt;br /&gt;&lt;br /&gt;First, let's create a table for this tutorial using SQL.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;CREATE TABLE IF NOT EXISTS `employees` (&lt;br /&gt;  `employee_id` int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;  `first_name` varchar(30) NOT NULL,&lt;br /&gt;  `last_name` varchar(30) NOT NULL,&lt;br /&gt;  `email` varchar(50) NOT NULL,&lt;br /&gt;  `phone_number` varchar(15) NOT NULL,&lt;br /&gt;  PRIMARY KEY  (`employee_id`)&lt;br /&gt;) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=121;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Then, we insert records to the table using SQL again.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;INSERT INTO `employees` (&lt;br /&gt;`employee_id`, `first_name`, `last_name`, `email`, `phone_number`) &lt;br /&gt;VALUES&lt;br /&gt;(100, 'Steven', 'King', 'SKING', '515.123.4567'),&lt;br /&gt;(101, 'Neena', 'Kochhar', 'NKOCHHAR', '515.123.4568'),&lt;br /&gt;(102, 'Lex', 'De Haan', 'LDEHAAN', '515.123.4569'),&lt;br /&gt;(103, 'Alexander', 'Hunold', 'AHUNOLD', '590.423.4567'),&lt;br /&gt;(104, 'Bruce', 'Ernst', 'BERNST', '590.423.4568'),&lt;br /&gt;(105, 'David', 'Austin', 'DAUSTIN', '590.423.4569'),&lt;br /&gt;(106, 'Valli', 'Pataballa', 'VPATABAL', '590.423.4560'),&lt;br /&gt;(107, 'Diana', 'Lorentz', 'DLORENTZ', '590.423.5567'),&lt;br /&gt;(108, 'Nancy', 'Greenberg', 'NGREENBE', '515.124.4569'),&lt;br /&gt;(109, 'Daniel', 'Faviet', 'DFAVIET', '515.124.4169'),&lt;br /&gt;(110, 'John', 'Chen', 'JCHEN', '515.124.4269'),&lt;br /&gt;(111, 'Ismael', 'Sciarra', 'ISCIARRA', '515.124.4369'),&lt;br /&gt;(112, 'Jose Manuel', 'Urman', 'JMURMAN', '515.124.4469'),&lt;br /&gt;(113, 'Luis', 'Popp', 'LPOPP', '515.124.4567'),&lt;br /&gt;(114, 'Den', 'Raphaely', 'DRAPHEAL', '515.127.4561'),&lt;br /&gt;(115, 'Alexander', 'Khoo', 'AKHOO', '515.127.4562'),&lt;br /&gt;(116, 'Shelli', 'Baida', 'SBAIDA', '515.127.4563'),&lt;br /&gt;(117, 'Sigal', 'Tobias', 'STOBIAS', '515.127.4564'),&lt;br /&gt;(118, 'Guy', 'Himuro', 'GHIMURO', '515.127.4565'),&lt;br /&gt;(119, 'Karen', 'Colmenares', 'KCOLMENA', '515.127.4566'),&lt;br /&gt;(120, 'Matthew', 'Weiss', 'MWEISS', '650.123.1234');&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, let's copy the table data including the definition.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;CREATE TABLE emp AS SELECT * FROM employees&lt;/pre&gt;&lt;br /&gt;   &lt;br /&gt;Here's to copy the table definition without the data&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;CREATE TABLE emp AS SELECT * FROM employees WHERE 1 = 0&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And here's to copy the seleted table data including the definition using MySQL's &lt;code&gt;LIMIT&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;CREATE TABLE emp AS SELECT * FROM employees LIMIT 0, 10&lt;/pre&gt;&lt;br /&gt;   &lt;br /&gt;And the last but not least, let's copy the seleted table column including the definition&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;CREATE TABLE emp AS SELECT first_name, last_name FROM employees&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The last four SQL scripts about creates a table named &lt;b&gt;emp&lt;/b&gt; from the result of the &lt;code&gt;SELECT&lt;/code&gt; statement. &lt;br /&gt;&lt;br /&gt;There are other variations of the &lt;code&gt;CREATE TABLE [table] AS SELECT&lt;/code&gt; statements that I haven't included here, some of them I don't know yet. I'll update this post as soon as I find more.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-1301156330712256539?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/1301156330712256539/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=1301156330712256539" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/1301156330712256539?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/1301156330712256539?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/sql-how-to-copy-database-table.html" title="SQL: How to Copy the Database Table Definition and Data Using SQL Scripts" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkAGR3YyfSp7ImA9WxVSE00.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-7902093878837175743</id><published>2009-01-06T22:36:00.002-05:00</published><updated>2009-01-06T22:58:46.895-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-06T22:58:46.895-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: How to Format Date Using date and strtotime Functions</title><content type="html">In PHP formatting a date to your desired format is so easy using the &lt;code&gt;date&lt;/code&gt; and &lt;code&gt;strtotime&lt;/code&gt; functions.&lt;br /&gt;&lt;br /&gt;According to the &lt;a href="http://us2.php.net/manual/en/function.strtotime.php"&gt;PHP documentation&lt;/a&gt; &lt;code&gt;strtotime&lt;/code&gt; parses any English textual datetime description into a Unix timestamp. It expects to be given a string containing a US English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC)&lt;br /&gt;                    &lt;br /&gt;Syntax: &lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;int strtotime  ( string $time  [, int $now  ] )&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Example: &lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;print strtotime("Dec. 25, 2008 10:00 AM");&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The &lt;code&gt;date&lt;/code&gt; function on the other hand returns a string formatted time/date according to the given format string using the given integer timestamp or the current time if no timestamp is given.&lt;br /&gt;&lt;br /&gt;Syntax: &lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;string date  ( string $format  [, int $timestamp  ] )&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Example: &lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;print date("M d, Y H:i:s A");&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So much for the long explanation. Here's how to format a date using the both functions. &lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;print date("M d, Y H:i:s A", strtotime("Dec. 25, 2008 10:00 AM"));&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;For the complete list of format for the &lt;code&gt;date&lt;/code&gt; functions, visit the PHP documentation &lt;a href="http://us2.php.net/manual/en/function.date.php"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-7902093878837175743?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/7902093878837175743/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=7902093878837175743" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/7902093878837175743?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/7902093878837175743?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2009/01/php-how-to-format-date-using-date-and.html" title="PHP: How to Format Date Using date and strtotime Functions" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;CUEFRX8-fSp7ImA9WxVTFkk.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-8001640201295145082</id><published>2008-12-30T07:40:00.005-05:00</published><updated>2008-12-30T08:26:54.155-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-30T08:26:54.155-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: How to Dynamically Alternate the Table Row Background Color</title><content type="html">In PHP, making the &lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt; row background color alternate dynamically is relatively easy. The key here is PHP's modulo (&lt;code&gt;%&lt;/code&gt;) operator. Using the &lt;code&gt;%&lt;/code&gt; operator inside a &lt;code&gt;loop&lt;/code&gt; construct, you can reference every other row in an HTML &lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt;. See the example below.&lt;br /&gt;&lt;br /&gt;Create the CSS rules.&lt;br /&gt;&lt;pre class="sourcecodes"&gt;.alt-color-1{&lt;br /&gt; background-color:red;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.alt-color-2{&lt;br /&gt; background-color:green;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Create the PHP script.&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;print "&amp;lt;table width='200' border='1' cellspacing='1' cellpadding='1'&amp;gt;";&lt;br /&gt;for ($i = 0; $i &amp;lt; 10; $i++)&lt;br /&gt;{&lt;br /&gt;if (($i % 2) == 0)&lt;br /&gt; {&lt;br /&gt; $alt = "alt-color-1";&lt;br /&gt; }&lt;br /&gt;else&lt;br /&gt; {&lt;br /&gt; $alt = "alt-color-2";&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;print "&amp;lt;tr class='".$alt."'&amp;gt;";&lt;br /&gt;print "&amp;lt;td&amp;gt;".$i."&amp;lt;/td&amp;gt;";&lt;br /&gt;print "&amp;lt;td&amp;gt;".$i."&amp;lt;/td&amp;gt;";&lt;br /&gt;print "&amp;lt;/tr&amp;gt;";&lt;br /&gt;}&lt;br /&gt;print "&amp;lt;/table&amp;gt;";&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Put it all together.&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;lt;title&amp;gt;Alternate Color in Table Rows&amp;lt;/title&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;style&amp;gt;&lt;br /&gt;.alt-color-1{&lt;br /&gt; background-color:red;&lt;br /&gt;}&lt;br /&gt;.alt-color-2{&lt;br /&gt; background-color:green;&lt;br /&gt;}&lt;br /&gt;&amp;lt;/style&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;print "&amp;lt;table width='200' border='1' cellspacing='1' cellpadding='1'&amp;gt;";&lt;br /&gt;&lt;br /&gt;for ($i = 0; $i &amp;lt; 10; $i++)&lt;br /&gt;{&lt;br /&gt;if (($i % 2) == 0) //USE THE MODULO OPERATOR&lt;br /&gt; {&lt;br /&gt; $alt = "alt-color-1";&lt;br /&gt; }&lt;br /&gt;else&lt;br /&gt; {&lt;br /&gt; $alt = "alt-color-2";&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;print "&amp;lt;tr class='".$alt."'&amp;gt;";&lt;br /&gt;print "&amp;lt;td&amp;gt;".$i."&amp;lt;/td&amp;gt;";&lt;br /&gt;print "&amp;lt;td&amp;gt;".$i."&amp;lt;/td&amp;gt;";&lt;br /&gt;print "&amp;lt;/tr&amp;gt;";&lt;br /&gt;}&lt;br /&gt;print "&amp;lt;/table&amp;gt;";&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;After executing the PHP script, here's what the webpage will look.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_HWU3wX2cDLQ/SVogp8cBD1I/AAAAAAAAExE/nnuZ7ZhmLP0/s1600-h/alternate_background_color.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 323px;" src="http://1.bp.blogspot.com/_HWU3wX2cDLQ/SVogp8cBD1I/AAAAAAAAExE/nnuZ7ZhmLP0/s400/alternate_background_color.png" border="0" alt="PHP: How to Dynamically Alternate the Table Row Background Color" id="BLOGGER_PHOTO_ID_5285573017643061074" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-8001640201295145082?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/8001640201295145082/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=8001640201295145082" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/8001640201295145082?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/8001640201295145082?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2008/12/php-how-to-dynamically-alternate-table.html" title="PHP: How to Dynamically Alternate the Table Row Background Color" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_HWU3wX2cDLQ/SVogp8cBD1I/AAAAAAAAExE/nnuZ7ZhmLP0/s72-c/alternate_background_color.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C04GRngycCp7ImA9WxVTE0g.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-8387916076365736613</id><published>2008-12-26T22:57:00.007-05:00</published><updated>2008-12-26T23:25:27.698-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-26T23:25:27.698-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: How to Display The Current Month in Calendar Style</title><content type="html">Displaying the current month in a calendar style is very handy and user-friendly for a website, specially for a blog. Using a calendar-style navigation your visitors can easily navigate through your previous posts and articles.&lt;br /&gt;&lt;br /&gt;Fortunately, in PHP, this seemingly difficult task in HTML is relatively easy. Just by using a nested &lt;code&gt;For Loop&lt;/code&gt; and PHP's &lt;code&gt;Date&lt;/code&gt; functions, use can build your own calendar.&lt;br /&gt;&lt;br /&gt;Here's the simple source code.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;&amp;lt;?php&lt;br /&gt;  $now = getdate(time());&lt;br /&gt;  $time = mktime(0,0,0, $now['mon'], 1, $now['year']);&lt;br /&gt;  $date = getdate($time);&lt;br /&gt;  $dayTotal = cal_days_in_month(0, $date['mon'], $date['year']);&lt;br /&gt;  &lt;br /&gt;  print '&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td colspan="7"&amp;gt;&amp;lt;strong&amp;gt;' . $date['month'] . '&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';&lt;br /&gt;  for ($i = 0; $i &amp;lt; 6; $i++) &lt;br /&gt;    {&lt;br /&gt;    print '&amp;lt;tr&amp;gt;';&lt;br /&gt;    for ($j = 1; $j &amp;lt;= 7; $j++) &lt;br /&gt;      {&lt;br /&gt;      $dayNum = $j + $i*7 - $date['wday'];      &lt;br /&gt;      print '&amp;lt;td';&lt;br /&gt;      if ($dayNum &amp;gt; 0 &amp;&amp; $dayNum &amp;lt;= $dayTotal) &lt;br /&gt;        {&lt;br /&gt;        print ($dayNum == $now['mday']) ? ' style="background: #aaa;"&amp;gt;' : '&amp;gt;';&lt;br /&gt;        print $dayNum;&lt;br /&gt;        }&lt;br /&gt;      else &lt;br /&gt;        {&lt;br /&gt;        print '&amp;gt;';&lt;br /&gt;        }&lt;br /&gt;      print '&amp;lt;/td&amp;gt;';&lt;br /&gt;      }&lt;br /&gt;    print '&amp;lt;/tr&amp;gt;';&lt;br /&gt;    if ($dayNum &amp;gt;= $dayTotal &amp;&amp; $i != 6)&lt;br /&gt;      {&lt;br /&gt;      break;&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;  print '&amp;lt;/table&amp;gt;';&lt;br /&gt;?&amp;gt;&lt;/pre&gt;&lt;br /&gt;Here's how the calendar will look like.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_HWU3wX2cDLQ/SVWq6KsUzcI/AAAAAAAAEuo/Deo-AUFbFbI/s1600-h/simple_php_calendar.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 320px;" src="http://4.bp.blogspot.com/_HWU3wX2cDLQ/SVWq6KsUzcI/AAAAAAAAEuo/Deo-AUFbFbI/s400/simple_php_calendar.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5284317654068547010" /&gt;&lt;/a&gt;&lt;br /&gt;To make it fancier, all you have to do now is use CSS to add colors and styles.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-8387916076365736613?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/8387916076365736613/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=8387916076365736613" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/8387916076365736613?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/8387916076365736613?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2008/12/php-how-to-display-current-month-in.html" title="PHP: How to Display The Current Month in Calendar Style" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_HWU3wX2cDLQ/SVWq6KsUzcI/AAAAAAAAEuo/Deo-AUFbFbI/s72-c/simple_php_calendar.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DE4AQXg9cSp7ImA9WxRaGEo.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-5729522254962327730</id><published>2008-12-21T11:29:00.002-05:00</published><updated>2008-12-21T11:29:00.669-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-21T11:29:00.669-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="technology" /><category scheme="http://www.blogger.com/atom/ns#" term="ramblings" /><title>My First Ubuntu Machine, and I'm Loving it</title><content type="html">My first encounter with &lt;a href="http://www.ubuntu.com/"&gt;Ubuntu&lt;/a&gt; was more than a year ago. Back then I was using Windows XP both at work and at home. By then, I tried installing it as a secondary boot in my XP desktop at home but it just wouldn't load after the installation so I didn't force it. &lt;br /&gt;&lt;br /&gt;More than two weeks ago, I finally completed my desktop. It took me more than a month to build because I have to wait the parts (LCD monitor, casing, keyboard, mouse and power supply) that I bought from Amazon. I can say that it's worth the wait because this is my first &lt;a href="http://ubuntu.com"&gt;Ubuntu&lt;/a&gt; machine and I'm loving it. I got Ubuntu 8.10 installed in it.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_HWU3wX2cDLQ/SU3HN50fJ-I/AAAAAAAAEtY/6f-by-ppmtQ/s1600-h/ubuntu_machine.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 320px;" src="http://2.bp.blogspot.com/_HWU3wX2cDLQ/SU3HN50fJ-I/AAAAAAAAEtY/6f-by-ppmtQ/s400/ubuntu_machine.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5282096979648653282" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Though I am Windows user ever since, it wasn't difficult for to adjust to this new operating system. Like Windows, Ubuntu comes with softwares that you can use for your daily tasks. My problem with this OS is my printer is not working on it. Fortunately, I got a Macbook to print with. Other than that, I'm head over heels with it.&lt;br /&gt;&lt;br /&gt;With this first taste of Linux, I think I will not go back to Windows if given a choice.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-5729522254962327730?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/5729522254962327730/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=5729522254962327730" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/5729522254962327730?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/5729522254962327730?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2008/12/my-first-ubuntu-machine-and-im-loving.html" title="My First Ubuntu Machine, and I'm Loving it" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_HWU3wX2cDLQ/SU3HN50fJ-I/AAAAAAAAEtY/6f-by-ppmtQ/s72-c/ubuntu_machine.png" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0UBQH45fCp7ImA9WxVTFE0.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-8578897114210537513</id><published>2008-12-20T23:03:00.003-05:00</published><updated>2008-12-27T13:07:31.024-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-27T13:07:31.024-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: Checking If Email is Valid with filter_var Function</title><content type="html">In PHP 4, &lt;a href="http://www.joelbadinas.com/2008/01/how-to-check-if-email-address-is-valid.html"&gt;checking if an email is valid uses regular expressions&lt;/a&gt;. But with PHP 5, you can use the &lt;code&gt;filter_var&lt;/code&gt; function. This function returns the filtered data, or false if the filter fails.&lt;br /&gt;&lt;br /&gt;Here's the syntax.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;mixed filter_var ( mixed $variable [, int $filter [, mixed $options ]] )&lt;br /&gt;&lt;br /&gt;Where:&lt;br /&gt;variable = Value to filter.&lt;br /&gt;filter   = ID of a filter to use. Defaults to FILTER_SANITIZE_STRING.&lt;br /&gt;options  = Associative array of options or bitwise disjunction of flags.&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here's how to use the function.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;if (filter_var(trim($email), FILTER_VALIDATE_EMAIL))&lt;br /&gt;  {&lt;br /&gt;  echo $email . " is valid.";&lt;br /&gt;  }&lt;br /&gt;else&lt;br /&gt;  {&lt;br /&gt;  echo $email . " is invalid.";&lt;br /&gt;  }&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-8578897114210537513?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/8578897114210537513/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=8578897114210537513" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/8578897114210537513?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/8578897114210537513?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2008/12/php-checking-if-email-is-valid-with.html" title="PHP: Checking If Email is Valid with filter_var Function" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DU4HQXk-cSp7ImA9WxRaFE4.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-2851327168366099371</id><published>2008-12-16T09:20:00.004-05:00</published><updated>2008-12-16T09:32:10.759-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-16T09:32:10.759-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="the net" /><category scheme="http://www.blogger.com/atom/ns#" term="ramblings" /><title>Iraqi Reporter Throws Shoe to Us President George Bush</title><content type="html">I was in the office yesterday when I saw this video of an Iragi reporter throws his shoes to the Us President George Bush on CNN. &lt;br /&gt;&lt;br /&gt;Although this is a grave insult to the US president and things like these in the US is a federal offense, some says this is a good sign that democracy is slowly creeping in Iraq. Things like these didn't exist in Saddam Hussein's dictatorial government because they will surely behead the suspect without even an investigation.&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/VFX-dKpcDz8&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/VFX-dKpcDz8&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/ePGvxEtvThI&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/ePGvxEtvThI&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-2851327168366099371?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/2851327168366099371/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=2851327168366099371" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/2851327168366099371?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/2851327168366099371?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2008/12/iraqi-reporter-throws-shoe-to-us.html" title="Iraqi Reporter Throws Shoe to Us President George Bush" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkIFRHk_eSp7ImA9WxVSFE8.&quot;"><id>tag:blogger.com,1999:blog-37793319.post-8949821238362724917</id><published>2008-12-05T07:43:00.012-05:00</published><updated>2009-01-08T08:15:15.741-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-08T08:15:15.741-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="php" /><title>PHP: A Simple Function to Create an HTML Select Date Options</title><content type="html">Here's a simple PHP function to create a select date options that you can use in your HTML forms to let users select a date. This is simple and easy to use. Below is the function definition.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;//RETURN DATE OPTIONS IN HTML&lt;br /&gt;function get_date_options($year = 0000, $month = 00, $day = 00)&lt;br /&gt; {&lt;br /&gt; $ret_val = "";&lt;br /&gt;&lt;br /&gt; //ASSEMBLE MONTHS&lt;br /&gt; $options = "&amp;lt;option value='00'&amp;gt;MM&amp;lt;/option&amp;gt;";&lt;br /&gt; for ($i = 1; $i &amp;lt; 13; $i++)&lt;br /&gt;   {   &lt;br /&gt;   $attribute = "value='".$i."'";&lt;br /&gt;   if ($i == $month)&lt;br /&gt;     {&lt;br /&gt;     $attribute .= " selected ";&lt;br /&gt;     }&lt;br /&gt;   $options .= "&amp;lt;option ".$attribute."&amp;gt;".str_pad($i,2,0,STR_PAD_LEFT)."&amp;lt;/option&amp;gt;";&lt;br /&gt;   } &lt;br /&gt; $ret_val .=  "&amp;lt;select name='month'&amp;gt;".$options."&amp;lt;/select&amp;gt; / ";&lt;br /&gt;&lt;br /&gt; //ASSEMBLE DAYS&lt;br /&gt; $options = "&amp;lt;option value='00'&amp;gt;DD&amp;lt;/option&amp;gt;";&lt;br /&gt; for ($i = 1; $i &amp;lt; 32; $i++)&lt;br /&gt;   {&lt;br /&gt;   $attribute = "value='".$i."'";&lt;br /&gt;   if ($i == $day)&lt;br /&gt;     {&lt;br /&gt;     $attribute .= " selected ";&lt;br /&gt;     }&lt;br /&gt;   $options .= "&amp;lt;option ".$attribute."&amp;gt;".str_pad($i,2,0,STR_PAD_LEFT)."&amp;lt;/option&amp;gt;";&lt;br /&gt;   } &lt;br /&gt; $ret_val .=  "&amp;lt;select name='day'&amp;gt;".$options."&amp;lt;/select&amp;gt; / ";&lt;br /&gt;&lt;br /&gt; //ASSEMBLE YEARS&lt;br /&gt; $options = "&amp;lt;option value='0000'&amp;gt;YYYY&amp;lt;/option&amp;gt;";&lt;br /&gt; for ($i = 2008; $i &amp;lt; 2051; $i++)&lt;br /&gt;   {&lt;br /&gt;   $attribute = "value='".$i."'";&lt;br /&gt;   if ($i == $year)&lt;br /&gt;     {&lt;br /&gt;     $attribute .= " selected ";&lt;br /&gt;     }&lt;br /&gt;   $options .= "&amp;lt;option ".$attribute."&amp;gt;".$i."&amp;lt;/option&amp;gt;";&lt;br /&gt;   } &lt;br /&gt; $ret_val .=  "&amp;lt;select name='year'&amp;gt;".$options."&amp;lt;/select&amp;gt;";&lt;br /&gt;&lt;br /&gt; return $ret_val;&lt;br /&gt; }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here's a simple way to use it.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;Enter your birthday : &amp;lt;?php print get_date_options() ?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And here's a way to use it to make default to a date.&lt;br /&gt;&lt;br /&gt;&lt;pre class="sourcecodes"&gt;Enter your birthday : &amp;lt;?php print get_date_options("2008", "12", "05") ?&amp;gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/37793319-8949821238362724917?l=kabalweg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://kabalweg.blogspot.com/feeds/8949821238362724917/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=37793319&amp;postID=8949821238362724917" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/8949821238362724917?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/37793319/posts/default/8949821238362724917?v=2" /><link rel="alternate" type="text/html" href="http://kabalweg.blogspot.com/2008/12/simple-php-function-to-create-select.html" title="PHP: A Simple Function to Create an HTML Select Date Options" /><author><name>kabalweg</name><uri>http://www.blogger.com/profile/09980005746056415488</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="31" height="32" src="http://photos1.blogger.com/blogger/7702/2891/1600/blog_photo.jpg" /></author><thr:total>0</thr:total></entry></feed>

