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

<channel>
	<title>web development tutorials</title>
	<atom:link href="http://www.maheshchari.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maheshchari.com</link>
	<description></description>
	<lastBuildDate>Sun, 05 May 2013 14:37:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>android get available memory stats</title>
		<link>http://www.maheshchari.com/android-get-available-memory-stats/</link>
		<comments>http://www.maheshchari.com/android-get-available-memory-stats/#comments</comments>
		<pubDate>Sun, 05 May 2013 14:37:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[device]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=887</guid>
		<description><![CDATA[Here is a basic device utility class that list out all device storage info. Available internal memory size. Total internal memory size. Available external memory size. Total external memory size. Remember to use this utility we need application READ_EXTERNAL_STORAGE . In code i did not imported required packages as it depends upon your application project<p><a class="excerpt-more blog-excerpt" href="http://www.maheshchari.com/android-get-available-memory-stats/">Read More...</a></p>]]></description>
				<content:encoded><![CDATA[<!-- google_ad_section_start -->
<p>Here is a basic device utility class that list out all device storage info.</p>
<ul>
<li>Available internal memory size.</li>
<li>Total internal memory size.</li>
<li>Available external memory size.</li>
<li>Total external memory size.</li>
</ul>
<p>Remember to use this utility we need application <a href="http://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE">READ_EXTERNAL_STORAGE</a> .<br />
In code i did not imported required packages as it depends upon your application project packages.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DeviceInfoUtil <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #003399;">Context</span> mContext<span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">public</span> DeviceInfoUtil<span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span> mContext<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">mContext</span> <span style="color: #339933;">=</span> mContext<span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> getTotalInternalMemorySize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">File</span> path <span style="color: #339933;">=</span> <span style="color: #003399;">Environment</span>.<span style="color: #006633;">getDataDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    StatFs stat <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StatFs<span style="color: #009900;">&#40;</span>path.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">long</span> blockSize <span style="color: #339933;">=</span> stat.<span style="color: #006633;">getBlockSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">long</span> totalBlocks <span style="color: #339933;">=</span> stat.<span style="color: #006633;">getBlockCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> totalBlocks <span style="color: #339933;">*</span> blockSize<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> getAvailableInternalMemorySize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">File</span> path <span style="color: #339933;">=</span> <span style="color: #003399;">Environment</span>.<span style="color: #006633;">getDataDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    StatFs stat <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StatFs<span style="color: #009900;">&#40;</span>path.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">long</span> blockSize <span style="color: #339933;">=</span> stat.<span style="color: #006633;">getBlockSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">long</span> availableBlocks <span style="color: #339933;">=</span> stat.<span style="color: #006633;">getAvailableBlocks</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> availableBlocks <span style="color: #339933;">*</span> blockSize<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> getTotalExternelMemorySize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">File</span> path <span style="color: #339933;">=</span> <span style="color: #003399;">Environment</span>.<span style="color: #006633;">getExternalStorageDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    StatFs stat <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StatFs<span style="color: #009900;">&#40;</span>path.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">long</span> blockSize <span style="color: #339933;">=</span> stat.<span style="color: #006633;">getBlockSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">long</span> totalBlocks <span style="color: #339933;">=</span> stat.<span style="color: #006633;">getBlockCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> totalBlocks <span style="color: #339933;">*</span> blockSize<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> getAvailableExternelMemorySize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">File</span> path <span style="color: #339933;">=</span> <span style="color: #003399;">Environment</span>.<span style="color: #006633;">getExternalStorageDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    StatFs stat <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StatFs<span style="color: #009900;">&#40;</span>path.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">long</span> blockSize <span style="color: #339933;">=</span> stat.<span style="color: #006633;">getBlockSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">long</span> availableBlocks <span style="color: #339933;">=</span> stat.<span style="color: #006633;">getAvailableBlocks</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> availableBlocks <span style="color: #339933;">*</span> blockSize<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/android-get-available-memory-stats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Delete Folder Recursively</title>
		<link>http://www.maheshchari.com/android-delete-folder-recursively/</link>
		<comments>http://www.maheshchari.com/android-delete-folder-recursively/#comments</comments>
		<pubDate>Sun, 05 May 2013 13:42:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=885</guid>
		<description><![CDATA[Here is a small snippet that is helpful for delete a folder on external SD-card of device. Remember you need to add a use permission in manifesto file of application. uses-permission android:name=&#34;android.permission.WRITE_EXTERNAL_STORAGE&#34; Here is snippet , you can add it to your file utility class in helpers package of your application public static boolean deleteFile&#40;File<p><a class="excerpt-more blog-excerpt" href="http://www.maheshchari.com/android-delete-folder-recursively/">Read More...</a></p>]]></description>
				<content:encoded><![CDATA[<!-- google_ad_section_start -->
<p>Here is a small snippet that is helpful for delete a folder on external SD-card of device. Remember you need to add a use permission in manifesto file of application.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="text" style="font-family:monospace;">uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;</pre></td></tr></table></div>

<p>Here is snippet , you can add it to your file utility class in helpers package of your application</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">boolean</span> deleteFile<span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span> file<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>file <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>file.<span style="color: #006633;">isDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> children <span style="color: #339933;">=</span> file.<span style="color: #006633;">list</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> children.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		    <span style="color: #000066; font-weight: bold;">boolean</span> success <span style="color: #339933;">=</span> deleteFile<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>file, children<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>success<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		    <span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	    <span style="color: #009900;">&#125;</span>
	    <span style="color: #000000; font-weight: bold;">return</span> file.<span style="color: #006633;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/android-delete-folder-recursively/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Mysql pagination tutorial</title>
		<link>http://www.maheshchari.com/php-mysql-pagination-tutorial/</link>
		<comments>http://www.maheshchari.com/php-mysql-pagination-tutorial/#comments</comments>
		<pubDate>Wed, 24 Apr 2013 10:22:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/mysql]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=879</guid>
		<description><![CDATA[PHP Mysql pagination tutorial We covered how to display mysql data in HTML table in my previous tutorial, now we are going to learn how to display perfect pagination for displaying mysql data in this tutorial. i have written inline comments in code, please go through it and let me know if you have confusion<p><a class="excerpt-more blog-excerpt" href="http://www.maheshchari.com/php-mysql-pagination-tutorial/">Read More...</a></p>]]></description>
				<content:encoded><![CDATA[<!-- google_ad_section_start -->
<p>PHP Mysql pagination tutorial</p>
<p>We covered how to display mysql data in HTML table in my previous <a href="http://www.maheshchari.com/display-mysql-table-data-in-html-table-with-php/" target="_blank">tutorial</a>, now we are going to learn how to display perfect pagination for displaying mysql data in this tutorial. i have written inline comments in code, please go through it and let me know if you have confusion or further improvement in coding or tutorial. </p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//auther : http://maheshchari.com</span>
<span style="color: #666666; font-style: italic;">//connect to mysql server with host,username,password</span>
<span style="color: #666666; font-style: italic;">//if connection fails stop further execution and show mysql error</span>
<span style="color: #000088;">$connection</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//select a database for given connection</span>
<span style="color: #666666; font-style: italic;">//if database selection  fails stop further execution and show mysql error</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test'</span><span style="color: #339933;">,</span><span style="color: #000088;">$connection</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">//we are displaying 5 results per page</span>
<span style="color: #000088;">$per_page</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//number of adjacent links we show left and right of the current page.</span>
<span style="color: #000088;">$adjacents</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//execute a mysql query to retrieve count of total users in table</span>
<span style="color: #666666; font-style: italic;">//if  query  fails stop further execution and show mysql error</span>
<span style="color: #000088;">$pages_query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT COUNT('id') FROM users&quot;</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//get total number of pages to be shown from  total result</span>
<span style="color: #000088;">$pages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_result</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pages_query</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$per_page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//get current page from URL ,if not present set it to 1</span>
<span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//calculate actual start page with respect to Mysql </span>
<span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$per_page</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//execute a mysql query to retrieve  all result from current page by using LIMIT keyword in mysql</span>
<span style="color: #666666; font-style: italic;">//if  query  fails stop further execution and show mysql error</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM users LIMIT <span style="color: #006699; font-weight: bold;">$start</span>, <span style="color: #006699; font-weight: bold;">$per_page</span>&quot;</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// our main pagination logic goes here</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//store pagination result in a string so that we can place any where in page.</span>
<span style="color: #000088;">$pagination</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//if current page is first show first only else reduce 1 by current page</span>
<span style="color: #000088;">$Prev_Page</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>?<span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span><span style="color: #000088;">$page</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//if current page is last show last  only else add  1 to  current page</span>
<span style="color: #000088;">$Next_Page</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">&gt;=</span><span style="color: #000088;">$pages</span><span style="color: #009900;">&#41;</span>?<span style="color: #000088;">$page</span><span style="color: #339933;">:</span><span style="color: #000088;">$page</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>	
&nbsp;
<span style="color: #666666; font-style: italic;">//if we are not on first page show first link</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">!=</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$pagination</span><span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;a href=&quot;?page=1&quot;&gt;First&lt;/a&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//if we are not on first page show previous link</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">!=</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$pagination</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">'&lt;a href=&quot;?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$Prev_Page</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;&lt;code&gt;&lt;&lt;&lt;/code&gt;Previous&lt;/a&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//we are going to display 5 links on pagination bar</span>
<span style="color: #000088;">$numberoflinks</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//find the number of links to show on right of current page</span>
<span style="color: #000088;">$upage</span><span style="color: #339933;">=</span><span style="color: #990000;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #000088;">$numberoflinks</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #000088;">$numberoflinks</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//find the number of links to show on left of current page</span>
<span style="color: #000088;">$lpage</span><span style="color: #339933;">=</span><span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #000088;">$numberoflinks</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #000088;">$numberoflinks</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//if  number of links on left of current page are zero we start from 1</span>
<span style="color: #000088;">$lpage</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lpage</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>?<span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span><span style="color: #000088;">$lpage</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//find the number of links to show on right of current page and make sure it must be less than total number of pages</span>
<span style="color: #000088;">$upage</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lpage</span><span style="color: #339933;">==</span><span style="color: #000088;">$upage</span><span style="color: #009900;">&#41;</span>?<span style="color: #000088;">$upage</span><span style="color: #339933;">+</span><span style="color: #000088;">$numberoflinks</span><span style="color: #339933;">:</span><span style="color: #000088;">$upage</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$upage</span><span style="color: #339933;">&gt;</span><span style="color: #000088;">$pages</span><span style="color: #009900;">&#41;</span><span style="color: #000088;">$upage</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pages</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//start building links from left to right of current page</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color: #000088;">$lpage</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">&lt;=</span><span style="color: #000088;">$upage</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//if current building link is current page we don't show link,we show as text else we show as linkn	</span>
<span style="color: #000088;">$pagination</span><span style="color: #339933;">.=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">' &lt;strong&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$x</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/strong&gt;'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">' &lt;a href=&quot;?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$x</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$x</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt;'</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//we show next link and last link if user doesn't on last page</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">!=</span><span style="color: #000088;">$pages</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$pagination</span><span style="color: #339933;">.=</span>  <span style="color: #0000ff;">'  &lt;a href=&quot;?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$Next_Page</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;Next&gt;&gt;&lt;/a&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">!=</span><span style="color: #000088;">$pages</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$pagination</span><span style="color: #339933;">.=</span>  <span style="color: #0000ff;">' &lt;a href=&quot;?page='</span><span style="color: #339933;">.</span><span style="color: #000088;">$pages</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;Last&lt;/a&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//display final pagination bar.</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;div class=&quot;pagination&quot; style=&quot;text-align:center&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$pagination</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
&nbsp;
&lt;table width=&quot;100%&quot; border=&quot;0&quot;&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;Id&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;First Name&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;Last Name&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;Created&lt;/td&gt;
  &lt;/tr&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">//while we going through each row we display info</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//row id ?&gt;&lt;/td&gt;</span>
    <span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;center&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fname</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// row first name ?&gt;&lt;/td&gt;</span>
    <span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;center&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lname</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//row las tname  ?&gt;&lt;/td&gt;</span>
    <span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;center&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">created</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//row created time ?&gt;&lt;/td&gt;</span>
  <span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>      
<span style="color: #000000; font-weight: bold;">&lt;?php</span>       
	<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;/table&gt;
&lt;div class=&quot;pagination&quot; style=&quot;text-align:center&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$pagination</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;</pre></td></tr></table></div>

<p><a href="http://www.maheshchari.com/wp-content/uploads/2013/04/maheshchari.com_php_pagination_tutorial.zip">Download Source file </a></p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/php-mysql-pagination-tutorial/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Display Mysql table  Data in HTML table with PHP</title>
		<link>http://www.maheshchari.com/display-mysql-table-data-in-html-table-with-php/</link>
		<comments>http://www.maheshchari.com/display-mysql-table-data-in-html-table-with-php/#comments</comments>
		<pubDate>Wed, 24 Apr 2013 04:33:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/mysql]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=877</guid>
		<description><![CDATA[The following PHP code will collect the data from users table and show in HTML table: I have given inline code comments so that you can understand everything. Please visit my another tutorial in this series to display mysql data in php with pagination . &#60;?php /* create a database 'test',and execute these two query<p><a class="excerpt-more blog-excerpt" href="http://www.maheshchari.com/display-mysql-table-data-in-html-table-with-php/">Read More...</a></p>]]></description>
				<content:encoded><![CDATA[<!-- google_ad_section_start -->
<p>The following PHP  code will collect the data from users table and show in HTML table:<br />
I have given inline code comments so that you can understand everything. Please visit my another <a href="http://www.maheshchari.com/php-mysql-pagination-tutorial/">tutorial </a>in this series to display mysql data in php with pagination .</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">/*
create a database 'test',and execute these two query to run the demo
CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fname` varchar(255) DEFAULT NULL,
  `lname` varchar(255) DEFAULT NULL,
  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
&nbsp;
/*Data for the table `users` */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*insert  into `users`(`id`,`fname`,`lname`,`created`) 
values 
(1,'Mahesh','Chari','2013-04-24 09:45:42'),
(2,'Mahesh ','Guggilla','2013-04-24 09:45:55'),
(3,'Chari','Mahesh','2013-04-24 09:46:01');
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;!DOCTYPE html &gt;
&lt;html &gt;
&lt;head&gt;
&lt;title&gt;Display Mysql Data in table with PHP&lt;/title&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">//connect to mysql server with host,username,password</span>
<span style="color: #666666; font-style: italic;">//if connection fails stop further execution and show mysql error</span>
<span style="color: #000088;">$connection</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//select a database for given connection</span>
<span style="color: #666666; font-style: italic;">//if database selection  fails stop further execution and show mysql error</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test'</span><span style="color: #339933;">,</span><span style="color: #000088;">$connection</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//execute a mysql query to retrieve all the users from users table</span>
<span style="color: #666666; font-style: italic;">//if  query  fails stop further execution and show mysql error</span>
<span style="color: #000088;">$query</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM users&quot;</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//if we get any results we show them in table data</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;table width=&quot;100%&quot; border=&quot;0&quot;&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;Id&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;First Name&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;Last Name&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;Created&lt;/td&gt;
  &lt;/tr&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> 
  <span style="color: #666666; font-style: italic;">//while we going through each row we display info</span>
  <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//row id ?&gt;&lt;/td&gt;</span>
    <span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;center&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fname</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// row first name ?&gt;&lt;/td&gt;</span>
    <span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;center&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lname</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//row las tname  ?&gt;&lt;/td&gt;</span>
    <span style="color: #339933;">&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;center&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">created</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//row created time ?&gt;&lt;/td&gt;</span>
  <span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/table&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">//if we can't get results we show information</span>
<span style="color: #b1b100;">else</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;h3&gt;No Results found.&lt;/h3&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/display-mysql-table-data-in-html-table-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Update category post count in single mysql query</title>
		<link>http://www.maheshchari.com/update-category-post-count-in-single-mysql-query/</link>
		<comments>http://www.maheshchari.com/update-category-post-count-in-single-mysql-query/#comments</comments>
		<pubDate>Mon, 22 Apr 2013 08:45:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/mysql]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=874</guid>
		<description><![CDATA[Update category post count in single query Most of applications have categories and categories content. One category may have multiple posts ,one post may have multiple categories. It is normal practice to show top 10 categories with having number of posts in a categories for that we join categories ,posts and pivot table and grouping<p><a class="excerpt-more blog-excerpt" href="http://www.maheshchari.com/update-category-post-count-in-single-mysql-query/">Read More...</a></p>]]></description>
				<content:encoded><![CDATA[<!-- google_ad_section_start -->
<p>Update category post count in single query</p>
<p>Most of applications have categories and categories content. One category may have multiple posts ,one post may have multiple categories.</p>
<p> It is normal practice to show top 10 categories with having number of posts in a categories for that we join categories ,posts and pivot table and grouping by categories we get the order and count. Generally this query takes much time. </p>
<p>To make faster results we add a count column to the categories table and update the count in a single mysql query , later we display top 10 categories by number of count column . </p>
<p>&nbsp;</p>
<p>here below query is useful to update the count .</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> categories <span style="color: #66cc66;">,</span>
<span style="color: #66cc66;">&#40;</span>
<span style="color: #993333; font-weight: bold;">SELECT</span> sms_categories<span style="color: #66cc66;">.</span>fk_cat_id<span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #993333; font-weight: bold;">NUMBER</span>  
<span style="color: #993333; font-weight: bold;">FROM</span> sms <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> sms_categories 
<span style="color: #993333; font-weight: bold;">ON</span> sms_categories<span style="color: #66cc66;">.</span>fk_sms_id<span style="color: #66cc66;">=</span>sms<span style="color: #66cc66;">.</span>sms_id <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> sms_categories<span style="color: #66cc66;">.</span>fk_cat_id
<span style="color: #66cc66;">&#41;</span> temp
&nbsp;
<span style="color: #993333; font-weight: bold;">SET</span> categories<span style="color: #66cc66;">.</span>c_count<span style="color: #66cc66;">=</span>temp<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">NUMBER</span> 
<span style="color: #993333; font-weight: bold;">WHERE</span> categories<span style="color: #66cc66;">.</span>c_id<span style="color: #66cc66;">=</span>temp<span style="color: #66cc66;">.</span>fk_cat_id;</pre></td></tr></table></div>

<p>&nbsp;</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/update-category-post-count-in-single-mysql-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Commonly media queries that supports all devices</title>
		<link>http://www.maheshchari.com/commonly-media-queries-that-supports-all-devices/</link>
		<comments>http://www.maheshchari.com/commonly-media-queries-that-supports-all-devices/#comments</comments>
		<pubDate>Mon, 22 Apr 2013 05:35:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[media queries]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=871</guid>
		<description><![CDATA[Commonly used media queries for supporting almost every device. A responsive web designing means One site for every screen like Small , Medium and Large with help of HTML5 and CSS3 . Before HTMl5 and CSS3 there is a tradition that every screen or device has its own website. For example mobile site is different<p><a class="excerpt-more blog-excerpt" href="http://www.maheshchari.com/commonly-media-queries-that-supports-all-devices/">Read More...</a></p>]]></description>
				<content:encoded><![CDATA[<!-- google_ad_section_start -->
<h3>Commonly used media queries for supporting almost every device. </h3>
<p>A responsive web designing means <strong>One site for every screen</strong> like Small , Medium  and Large  with help of HTML5 and CSS3 . Before HTMl5 and CSS3 there is a tradition that every screen or device has its own website. For example mobile site is different from desk top site resulting heavy development hours , efforts<br />
  and client pocket also <img src='http://www.maheshchari.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>For designing a responsive site every web designer has some confusions which type of screen sizes he should use and what is the optimal minimum and maximum widths for media queries . After a long research i have found some common media queries that supports almost all mobile devices. </p>
<p>I have done research for below mobile ,tablets and desktop screens</p>
<ul>
<li>Iphone 5  (320 x 568) </li>
<li> Galaxy S III  (360 x 640)</li>
<li> Lumia 920  (384 x 640) </li>
<li> Iphone 4  (320 x 480) </li>
<li>Even Older Smartphones </li>
<li>Nexus One  (480 x 800) </li>
<li>Droid 2  (480 x 854) </li>
<li>iPad  (1024 x 768) </li>
<li> Galaxy Tab 10.1  (1280 x 800) </li>
<li>Galaxy Tab 2 (10.1) is the same,</li>
<li> Kindle Fire HD 7&#8243; is also. </li>
<li>Kindle Fire  (1024 x 600)</li>
<li> Kindle Fire HD 8.9&#8243;  (1920 x 1200)</li>
</ul>
<p>Below is common fix for media queries </p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Large desktop */</span>
<span style="color: #a1a100;">@media (min-width: 1200px) { </span>
&nbsp;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Portrait tablet to landscape and desktop */</span>
<span style="color: #a1a100;">@media (min-width: 768px) and (max-width: 979px) { </span>
&nbsp;
&nbsp;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Landscape phone to portrait tablet */</span>
<span style="color: #a1a100;">@media (max-width: 767px) { </span>
&nbsp;
&nbsp;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Landscape phones and down */</span>
<span style="color: #a1a100;">@media (max-width: 480px) { </span>
&nbsp;
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Please let me know if you have better media queries or any issues with these </p>
<p>&nbsp;</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/commonly-media-queries-that-supports-all-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>update multiple mysql tables</title>
		<link>http://www.maheshchari.com/update-multiple-mysql-tables/</link>
		<comments>http://www.maheshchari.com/update-multiple-mysql-tables/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 15:31:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/mysql]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=866</guid>
		<description><![CDATA[How to update multiple tables using single mysql query update sms ,categories set sms.sms_cats= categories.c_id where sms.sms_category=categories.c_name;]]></description>
				<content:encoded><![CDATA[<!-- google_ad_section_start -->
<h3>How to update multiple tables using single mysql query </h3>

<div class="wp_syntax"><table><tr><td class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">update</span> sms <span style="color: #000033;">,</span>categories 
<span style="color: #990099; font-weight: bold;">set</span> sms.sms_cats<span style="color: #CC0099;">=</span> categories.c_id 
<span style="color: #990099; font-weight: bold;">where</span> sms.sms_category<span style="color: #CC0099;">=</span>categories.c_name<span style="color: #000033;">;</span></pre></td></tr></table></div>

<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/update-multiple-mysql-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP nested categories with single mysql query</title>
		<link>http://www.maheshchari.com/php-nested-categories-with-single-mysql-query/</link>
		<comments>http://www.maheshchari.com/php-nested-categories-with-single-mysql-query/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 13:06:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/mysql]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[nested]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[recursive]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=863</guid>
		<description><![CDATA[Nested Categories example in PHP with single mysql query Most of the time it is basic requirement to build a nested categories in our projects , every time i was asked to write a basic tutorial in this regard. finally i got time to write this tutorial. In this tutorial i am writing a helper<p><a class="excerpt-more blog-excerpt" href="http://www.maheshchari.com/php-nested-categories-with-single-mysql-query/">Read More...</a></p>]]></description>
				<content:encoded><![CDATA[<!-- google_ad_section_start -->
<p>Nested Categories example in PHP with single mysql query </p>
<p>Most of the time it is basic requirement to build a nested categories in our projects , every time i was asked to write a basic tutorial in this regard. finally i got time to write this tutorial. In this tutorial i am writing a helper class that is suitable for generating nested HTML structure that can be easy integrated with any JavaScript library and can be styled for nested menus. </p>
<p>Here is the example and comments are inline with code you can take the table structure i am following. </p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">/*
Table structure
_________________________________________
CREATE TABLE IF NOT EXISTS `categories` (
  `c_id` int(11) NOT NULL AUTO_INCREMENT,
  `c_name` varchar(255) DEFAULT NULL,
  `c_parent` int(11) DEFAULT '0',
  `c_order` int(11) DEFAULT '0',
  PRIMARY KEY (`c_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8  ;
_________________________________________
INSERT INTO `categories` 
(`c_id`, `c_name`, `c_parent`, `c_order`) 
VALUES
(1, 'first category', 0, 0),
(2, 'second category', 3, 0),
(3, 'third category', 0, 0),
(4, 'fourth category', 2, 0),
(5, 'fifth category', 1, 0);
&nbsp;
*/</span>
&nbsp;
<span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'yiicoupon'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
PHP class that generate nested order list from the database. 
Here we use single mysql query .
We iterate through the single array that returned from mysql recursively. 
*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> netstedCategories <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*This function generate HTML output from the recursive array of categories */</span>
	<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> generateMenu<span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span><span style="color: #339933;">,</span><span style="color: #000088;">$level</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;ol id=&quot;level_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$level</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$category</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li id=&quot;item_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">c_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; &gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">c_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">children</span><span style="color: #009900;">&#41;</span> and <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">children</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				netstedCategories<span style="color: #339933;">::</span><span style="color: #004000;">generateMenu</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">children</span><span style="color: #339933;">,</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">c_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/ol&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> static  <span style="color: #000000; font-weight: bold;">function</span> buildMenu  <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$categories</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$query</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'select * from  categories order by c_order asc'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$categories</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$row</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #666666; font-style: italic;">//we start with root categories first</span>
		<span style="color: #000088;">$nestedCategories</span><span style="color: #339933;">=</span>netstedCategories<span style="color: #339933;">::</span><span style="color: #004000;">getChildren</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		netstedCategories<span style="color: #339933;">::</span><span style="color: #004000;">generateMenu</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nestedCategories</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*Check if a category has children by passing total categories and parent id*/</span>
	<span style="color: #000000; font-weight: bold;">public</span> static  <span style="color: #000000; font-weight: bold;">function</span>  hasChildren<span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span><span style="color: #339933;">,</span><span style="color: #000088;">$parent_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//if we found any single category that parent id is equal to given category id</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">c_parent</span><span style="color: #339933;">==</span><span style="color: #000088;">$parent_id</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//if we won't find anything we return false;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*A recursive public static function that is responsible to build nested array*/</span>
	<span style="color: #000000; font-weight: bold;">public</span> static  <span style="color: #000000; font-weight: bold;">function</span> getChildren<span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span> <span style="color: #339933;">,</span><span style="color: #000088;">$parent_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$temp</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">/*We take care about given parent id ,remaning we skip*/</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">c_parent</span><span style="color: #339933;">==</span><span style="color: #000088;">$parent_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>netstedCategories<span style="color: #339933;">::</span><span style="color: #004000;">hasChildren</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span><span style="color: #339933;">,</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">c_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #666666; font-style: italic;">/*if present category has children we call this function again by passing categories
					array and current category id*/</span>
					<span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">children</span><span style="color: #339933;">=</span>netstedCategories<span style="color: #339933;">::</span><span style="color: #004000;">getChildren</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span><span style="color: #339933;">,</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">c_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #000088;">$temp</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$category</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$temp</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
netstedCategories<span style="color: #339933;">::</span><span style="color: #004000;">buildMenu</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
________________________________
Final output looks like below
________________________________
&lt;ol id=&quot;level_0&quot;&gt;
  &lt;li id=&quot;item_1&quot; &gt;
    &lt;div&gt;first category&lt;/div&gt;
    &lt;ol id=&quot;level_1&quot;&gt;
      &lt;li id=&quot;item_5&quot; &gt;
        &lt;div&gt;fifth category&lt;/div&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li id=&quot;item_3&quot; &gt;
    &lt;div&gt;third category&lt;/div&gt;
    &lt;ol id=&quot;level_3&quot;&gt;
      &lt;li id=&quot;item_2&quot; &gt;
        &lt;div&gt;second category&lt;/div&gt;
        &lt;ol id=&quot;level_2&quot;&gt;
          &lt;li id=&quot;item_4&quot; &gt;
            &lt;div&gt;fourth category&lt;/div&gt;
          &lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/php-nested-categories-with-single-mysql-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>install Java</title>
		<link>http://www.maheshchari.com/install-java/</link>
		<comments>http://www.maheshchari.com/install-java/#comments</comments>
		<pubDate>Fri, 19 Apr 2013 07:26:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=857</guid>
		<description><![CDATA[How do I install Java ? Installing Java on windows Step 1 Java SE is freely available from the link So you download a version based on your operating system.Once you installed Java on your machine, Let&#8217;s set environment variables. Step 2 Suppose you have installed Java in c:\Program Files\java\jdk directory Right-click on &#8216;My Computer&#8216;<p><a class="excerpt-more blog-excerpt" href="http://www.maheshchari.com/install-java/">Read More...</a></p>]]></description>
				<content:encoded><![CDATA[<!-- google_ad_section_start -->
<h2>How do I install Java ? </h2>
<h3>Installing Java on windows</h3>
<div>
<p><strong>Step 1</strong></p>
<p>Java SE is freely available from the <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk6-jsp-136632.html" target="_blank" rel="nofollow">link</a> So you download a version based on your operating system.Once you   installed Java on your machine, Let&#8217;s set environment variables. </p>
</div>
<div>
<p><strong>Step 2 </strong></p>
<p>Suppose you have installed Java in <strong>c:\Program Files\java\jdk</strong> directory<br />
    Right-click on &#8216;<strong>My Computer</strong>&#8216; and select <strong>&#8216;Properties&#8217;</strong>.<br />
    Click on the &#8216;<strong>Environment variables</strong>&#8216; button under the &#8216;<strong>Advanced&#8217; tab</strong>.<br />
    Change the &#8216;Path&#8217; variable so that it also contains the path to the Java executable.<br />
    Append this to your path &#8211; <strong>c:\Program Files\java\jdk\bin</strong>
  </p>
<p><a href="http://www.maheshchari.com/wp-content/uploads/2013/04/editing-system-environment-variables.jpg"><img src="http://www.maheshchari.com/wp-content/uploads/2013/04/editing-system-environment-variables.jpg" alt="editing-system-environment-variables" width="500" height="320" class="aligncenter size-full wp-image-858" /></a></p>
<p><a href="http://www.maheshchari.com/wp-content/uploads/2013/04/Windows_XP_Environment_Variables.png"><img src="http://www.maheshchari.com/wp-content/uploads/2013/04/Windows_XP_Environment_Variables.png" alt="Windows_XP_Environment_Variables" width="384" height="430" class="aligncenter size-full wp-image-859" /></a></p>
</div>
<div>
<p><strong>Step 3</strong></p>
<p>In the command prompt enter command javac.<br />
    If you see a screen like below. Java is Installed. </p>
</div>
<p><a href="http://www.maheshchari.com/wp-content/uploads/2013/04/java_check_installed.png"><img src="http://www.maheshchari.com/wp-content/uploads/2013/04/java_check_installed.png" alt="java_check_installed" width="677" height="474" class="aligncenter size-full wp-image-860" /></a></p>
<p>&nbsp;</p>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/install-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to Java</title>
		<link>http://www.maheshchari.com/introduction-to-java/</link>
		<comments>http://www.maheshchari.com/introduction-to-java/#comments</comments>
		<pubDate>Fri, 19 Apr 2013 07:12:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[introduction]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=854</guid>
		<description><![CDATA[Introduction to Java Java is an object-oriented programming language with a built-in application programming interface (API) that can handle graphics and user interfaces and that can be used to create applications or applets. Because of its rich set of API&#8217;s, similar to Macintosh and Windows, and its platform independence, Java can also be thought of<p><a class="excerpt-more blog-excerpt" href="http://www.maheshchari.com/introduction-to-java/">Read More...</a></p>]]></description>
				<content:encoded><![CDATA[<!-- google_ad_section_start -->
<h2>Introduction to Java</h2>
<p><strong>Java is an object-oriented programming language</strong> with a built-in application programming interface (API) that can handle graphics and user interfaces and that can be used to create applications or applets. Because of its rich set of API&#8217;s, similar to Macintosh and Windows, and its platform independence, Java can also be thought of as a platform in itself. Java also has standard libraries for doing mathematics.</p>
<p>  <strong>Java </strong> was originally developed by Sun Micro systems, which was initiated by James Gosling and released in 1995 as core component of Sun Micro systems Java platform (Java 1.0 [J2SE]).</p>
<p>  As of December 08 the latest release of the Java Standard Edition is 7 (J2SE). With the advancement of Java and its wide spread popularity, multiple configurations were built to suite various types of platforms. Ex: J2EE for Enterprise Applications, J2ME for Mobile Applications.<br />
  Sun Micro systems has renamed the new J2 versions as Java SE, Java EE and Java ME respectively. Java is guaranteed to be Write Once, Run Anywhere </p>
<p><strong>Java features</strong></p>
<p><strong>Object Oriented : </strong>In java everything is an Object. Java can be easily extended since it is based on the Object model.<br />
<strong>Platform independent :</strong> Unlike many other programming languages including C and C++ when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by virtual Machine (JVM) on whichever platform it is being run.<br />
<strong>Simple :Java</strong> is designed to be easy to learn. If you understand the basic concept of OOP java would be easy to master.<br />
<strong>Secure :</strong> With Java&#8217;s secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption.<br />
<strong>Architectural &#8211; neutral :Java</strong> compiler generates an architecture-neutral object file format which makes the compiled code to be executable on many processors, with the presence Java run time system.<br />
<strong>Portable :</strong>being architectural neutral and having no implementation dependent aspects of the specification makes Java portable. Compiler and Java is written in ANSI C with a clean portability boundary which is a POSIX subset.<br />
<strong>Robust :Java</strong> makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and run time checking.<br />
<strong>Multi-threaded :</strong> With <strong>Java&#8217;s</strong> multi-threaded feature it is possible to write programs that can do many tasks simultaneously. This design feature allows developers to construct smoothly running interactive applications.<br />
<strong>Interpreted :Java</strong> byte code is translated on the fly to native machine instructions and is not stored anywhere. The development process is more rapid and analytical since the linking is an incremental and light weight process.<br />
<strong>High Performance :</strong> With the use of Just-In-Time compilers Java enables high performance.<br />
<strong>Distributed :Java</strong> is designed for the distributed environment of the internet.<br />
<strong>Dynamic : Java</strong> is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.</p>
<h2>History of  Java</h2>
<p>Java Programming Language was conceived by the effort of a small group of Sun engineers called the &#8220;Green Team&#8221; mainly comprises of 5  great people, James Gosling, Patrick Naughton, Chris Warth, Mike Sheridan and Ed Frank  came up with Java in 1991. The language took 18 months to develop and had a initial name as &#8220;Oak&#8221; which was renamed to Java in 1995, due to copyright issues. <br />
  Today, Java not only permeates the Internet, but also is the invisible force behind many of the applications and devices that power our day-to-day lives. From mobile phones to handheld devices, games and navigation systems to e-business solutions, Java is everywhere! <br />
  Java is not an ordinary programming language. It is a technology which is simple, Object Oriented, Distributed, Robust, Secure, Architecture neutral, Portable, Interpreted, Multi threaded, High Performance and Dynamic.
</p>
<p>Major release versions of <strong>Java</strong>, along with their release dates:</p>
<ul>
<li>JDK 1.0 (January 21, 1996)</li>
<li>JDK 1.1 (February 19, 1997)</li>
<li>J2SE 1.2 (December 8, 1998)</li>
<li>J2SE 1.3 (May 8, 2000)</li>
<li>J2SE 1.4 (February 6, 2002)</li>
<li>J2SE 5.0 (September 30, 2004)</li>
<li>Java SE 6 (December 11, 2006)</li>
<li>Java SE 7 (July 28, 2011)</li>
</ul>
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/introduction-to-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.076 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2013-05-05 15:06:06 -->

<!-- Compression = gzip -->