<?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>The Tech Space &#187; source code</title>
	<atom:link href="http://www.thetechspace.com/tag/source-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thetechspace.com</link>
	<description>php, jquery, flash and resources</description>
	<lastBuildDate>Fri, 21 May 2010 08:12:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Get Unlimited Parent and Child in PHP</title>
		<link>http://www.thetechspace.com/2010/05/21/get-unlimited-parent-and-child-in-php/</link>
		<comments>http://www.thetechspace.com/2010/05/21/get-unlimited-parent-and-child-in-php/#comments</comments>
		<pubDate>Fri, 21 May 2010 08:12:39 +0000</pubDate>
		<dc:creator>Thurein</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://www.thetechspace.com/?p=321</guid>
		<description><![CDATA[Well, let me ask you first. Have you already known about recursion? If not, recursion mean reuse function in this function.
How is it ? For eg Like
function one_function ($var){
           one_function(332);
}

OK , So , how to related with this post title ? I would like to [...]]]></description>
			<content:encoded><![CDATA[<p>Well, let me ask you first. Have you already known about recursion? If not, recursion mean reuse function in this function.</p>
<p>How is it ? For eg Like</p>
<pre class="brush:php">function one_function ($var){
           one_function(332);
}
</pre>
<p>OK , So , how to related with this post title ? I would like to say absolutely related with recursion. Let&#8217;s say, we would like to create category with parent and child.so, we have one table in database, category table. Table Structure Like:</p>

<table id="wp-table-reloaded-id-1-no-1" class="wp-table-reloaded wp-table-reloaded-id-1">
<thead>
	<tr class="row-1 odd">
		<th class="column-1">id</th><th class="column-2">name</th><th class="column-3">p_id</th>
	</tr>
</thead>
<tbody>
	<tr class="row-2 even">
		<td class="column-1">1</td><td class="column-2">Main Parent</td><td class="column-3">0</td>
	</tr>
	<tr class="row-3 odd">
		<td class="column-1">2</td><td class="column-2">Sub Parent</td><td class="column-3">1</td>
	</tr>
	<tr class="row-4 even">
		<td class="column-1">3</td><td class="column-2">Child</td><td class="column-3">2</td>
	</tr>
	<tr class="row-5 odd">
		<td class="column-1">4</td><td class="column-2">Parent 2</td><td class="column-3">0</td>
	</tr>
	<tr class="row-6 even">
		<td class="column-1">5</td><td class="column-2">Child 2</td><td class="column-3">4</td>
	</tr>
	<tr class="row-7 odd">
		<td class="column-1">6</td><td class="column-2">Child 3</td><td class="column-3">4</td>
	</tr>
	<tr class="row-8 even">
		<td class="column-1">7</td><td class="column-2">Child 4</td><td class="column-3">5</td>
	</tr>
</tbody>
</table>

<p><span id="more-321"></span>So, now I have created one table. I would like to get the out put like:</p>
<p>Main Parrent<br />
- Sub Parent<br />
&#8211; Child of sub parent<br />
Parent 2<br />
-  Child 2<br />
&#8211; Child of child 2<br />
- Child 3</p>
<p>So, how will you do it? How could we get it?</p>
<p>If you write the codes like, for eg :</p>
<pre class="brush:php">   $result = mysql_query ();
   while ( $row = mysql_fetch_assoc($result) ){

      echo $row[name];

      $result = mysql_query ();
      while ( $row = mysql_fetch_assoc($result) ){

            echo '- '.$row[name];
      }

   }
</pre>
<p>It would be work. But. If you have 3 or 4 or 5 levels and so on, you will got the trouble. So, what is the better way for that table? Shell we use recursion ?</p>
<p>I have wrote some code snippets like :</p>
<pre class="brush:php">function display_child($parent, $level) {

		$content= array();
		$sql = "SELECT * from test WHERE p_id='$parent'";
		$result = mysql_query($sql);
	   	while ($row = mysql_fetch_array($result)) {
		   	array_push($content,$row['id']);

			if (in_array($parent, $content)){
				echo $row['name']."
";

			}

			echo str_repeat('-',$level)." ".$row['name']."
";
			display_child($row['id'], $level+1);
	   }

}
</pre>
<p>Usage &#8211; display_child( parent_id, level )</p>
<pre class="brush:php">     display_children(0,0);
</pre>
<p>I hope it would be useful for some of your projects. Enjoy !!!!</p>
<h3><a href="http://www.thetechspace.com/?download=php_recursion" target="_blank">Download Source</a> ( size 2.7 kB)</h3>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://www.thetechspace.com/2010/05/21/get-unlimited-parent-and-child-in-php/&amp;title=Get+Unlimited+Parent+and+Child+in+PHP" rel="" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.thetechspace.com/2010/05/21/get-unlimited-parent-and-child-in-php/&amp;title=Get+Unlimited+Parent+and+Child+in+PHP" rel="" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.thetechspace.com/2010/05/21/get-unlimited-parent-and-child-in-php/&amp;title=Get+Unlimited+Parent+and+Child+in+PHP" rel="" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.thetechspace.com/2010/05/21/get-unlimited-parent-and-child-in-php/" rel="" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.thetechspace.com/2010/05/21/get-unlimited-parent-and-child-in-php/&amp;t=Get+Unlimited+Parent+and+Child+in+PHP" rel="" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Get+Unlimited+Parent+and+Child+in+PHP+-+http://tinyurl.com/2vqjo2w+(via+@lit_tiger)&amp;source=shareaholic" rel="" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.thetechspace.com/2010/05/21/get-unlimited-parent-and-child-in-php/&amp;title=Get+Unlimited+Parent+and+Child+in+PHP" rel="" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.thetechspace.com/2010/05/21/get-unlimited-parent-and-child-in-php/&amp;imageurl=" rel="" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="sexy-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.thetechspace.com/2010/05/21/get-unlimited-parent-and-child-in-php/&amp;title=Get+Unlimited+Parent+and+Child+in+PHP" rel="" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetechspace.com/2010/05/21/get-unlimited-parent-and-child-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL next and previous record of the current record</title>
		<link>http://www.thetechspace.com/2010/04/07/mysql-next-and-previous-record-of-the-current-record/</link>
		<comments>http://www.thetechspace.com/2010/04/07/mysql-next-and-previous-record-of-the-current-record/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 11:11:21 +0000</pubDate>
		<dc:creator>Thurein</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://www.thetechspace.com/?p=311</guid>
		<description><![CDATA[I have thought a lot these days what I should write some tips for beginner. Now, I got it. Have you ever noticed when you visiting and reading on some blogs? You will see previous and next links of current post. I don&#8217;t mean pagination links. If you have seen , have you ever thought [...]]]></description>
			<content:encoded><![CDATA[<p>I have thought a lot these days what I should write some tips for beginner. Now, I got it. Have you ever noticed when you visiting and reading on some blogs? You will see previous and next links of current post. I don&#8217;t mean pagination links. If you have seen , have you ever thought how to retrieve those data from MySQL ? OK , If you haven&#8217;t thought and tried yet. Let&#8217;s see how to do it.</p>
<p>Let says, we have user table. Normally, we write SQL query like :</p>
<pre class="brush:sql">SELECT * FROM user WHERE user_id = 111
</pre>
<p>OK, If your user_id is added by auto increment, it&#8217;s simply write 111 &#8211; 1 and 111 + 1 in your program. If not, how could we got it?<br />
Let&#8217;s see.</p>
<pre class="brush:sql">SELECT *,
(SELECT user_id FROM user WHERE user_id &lt; u.user_id ORDER BY user_id DESC LIMIT 1) AS user_prev,
(SELECT user_id FROM user WHERE user_id &gt; u.user_id ORDER BY user_id ASC LIMIT 1) AS user_next
FROM user AS u WHERE u.user_id=111
</pre>
<p>Enjoy !!! I hope it would be useful for you.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://www.thetechspace.com/2010/04/07/mysql-next-and-previous-record-of-the-current-record/&amp;title=MySQL+next+and+previous+record+of+the+current+record" rel="" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.thetechspace.com/2010/04/07/mysql-next-and-previous-record-of-the-current-record/&amp;title=MySQL+next+and+previous+record+of+the+current+record" rel="" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.thetechspace.com/2010/04/07/mysql-next-and-previous-record-of-the-current-record/&amp;title=MySQL+next+and+previous+record+of+the+current+record" rel="" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.thetechspace.com/2010/04/07/mysql-next-and-previous-record-of-the-current-record/" rel="" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.thetechspace.com/2010/04/07/mysql-next-and-previous-record-of-the-current-record/&amp;t=MySQL+next+and+previous+record+of+the+current+record" rel="" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=MySQL+next+and+previous+record+of+the+current+record+-+http://tinyurl.com/2vtd97d+(via+@lit_tiger)&amp;source=shareaholic" rel="" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.thetechspace.com/2010/04/07/mysql-next-and-previous-record-of-the-current-record/&amp;title=MySQL+next+and+previous+record+of+the+current+record" rel="" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.thetechspace.com/2010/04/07/mysql-next-and-previous-record-of-the-current-record/&amp;imageurl=" rel="" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="sexy-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.thetechspace.com/2010/04/07/mysql-next-and-previous-record-of-the-current-record/&amp;title=MySQL+next+and+previous+record+of+the+current+record" rel="" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetechspace.com/2010/04/07/mysql-next-and-previous-record-of-the-current-record/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to return more than one value or multi value in PHP</title>
		<link>http://www.thetechspace.com/2010/03/28/how-to-return-more-than-one-value-or-multi-value-in-php/</link>
		<comments>http://www.thetechspace.com/2010/03/28/how-to-return-more-than-one-value-or-multi-value-in-php/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 01:13:45 +0000</pubDate>
		<dc:creator>Thurein</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://www.thetechspace.com/?p=297</guid>
		<description><![CDATA[Some of PHP beginners (my friends) always ask me how to return two or more values from function. So , I thought, I may need to write the beginner tip at The Tech Space Blog. If your the advanced PHP programmer, you will say. So easy, It&#8217;s a piece of cake. For beginner, it would [...]]]></description>
			<content:encoded><![CDATA[<p>Some of PHP beginners (my friends) always ask me how to return two or more values from function. So , I thought, I may need to write the beginner tip at The Tech Space Blog. If your the advanced PHP programmer, you will say. So easy, It&#8217;s a piece of cake. For beginner, it would be a little difficult. So, let&#8217;s see how to write it.</p>
<p>For normal function ..</p>
<pre class="brush:php">
&lt;?

function calc ( $a, $b)
{

$sum = $a+$b;
return $sum;

}

echo $calc(2,3);

?&gt;
</pre>
<p>So, If you would like to return two or more value from that function, just only return as an array. Let&#8217;s see.</p>
<pre class="brush:php">
&lt;?php

function calc($a,$b){

$sum = $a+$b;
$multiply = $a * $b;
$divided = $a/$b;
$modulus = $a%$b;

return array( 'sum'=&gt;$sum, 'multiply'=&gt;$multiply, 'divided'=&gt; $divided, 'modulus'=&gt;$modulus );

}

$data = calc(3,4);

echo 'Sum value: '.$data['sum'].'&lt;br /&gt;';
echo 'Multiply value: '.$data['multiply'].'&lt;br /&gt;';
echo 'Divided value: '.$data['divided'].'&lt;br /&gt;';
echo 'Modulus value: '.$data['modulus'].'&lt;br /&gt;';

?&gt;
</pre>
<p>Enjoy !!!</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://www.thetechspace.com/2010/03/28/how-to-return-more-than-one-value-or-multi-value-in-php/&amp;title=How+to+return+more+than+one+value+or+multi+value+in+PHP" rel="" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.thetechspace.com/2010/03/28/how-to-return-more-than-one-value-or-multi-value-in-php/&amp;title=How+to+return+more+than+one+value+or+multi+value+in+PHP" rel="" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.thetechspace.com/2010/03/28/how-to-return-more-than-one-value-or-multi-value-in-php/&amp;title=How+to+return+more+than+one+value+or+multi+value+in+PHP" rel="" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.thetechspace.com/2010/03/28/how-to-return-more-than-one-value-or-multi-value-in-php/" rel="" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.thetechspace.com/2010/03/28/how-to-return-more-than-one-value-or-multi-value-in-php/&amp;t=How+to+return+more+than+one+value+or+multi+value+in+PHP" rel="" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=How+to+return+more+than+one+value+or+multi+value+in+PHP+-+http://tinyurl.com/yc47emv+(via+@lit_tiger)&amp;source=shareaholic" rel="" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.thetechspace.com/2010/03/28/how-to-return-more-than-one-value-or-multi-value-in-php/&amp;title=How+to+return+more+than+one+value+or+multi+value+in+PHP" rel="" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.thetechspace.com/2010/03/28/how-to-return-more-than-one-value-or-multi-value-in-php/&amp;imageurl=" rel="" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="sexy-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.thetechspace.com/2010/03/28/how-to-return-more-than-one-value-or-multi-value-in-php/&amp;title=How+to+return+more+than+one+value+or+multi+value+in+PHP" rel="" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetechspace.com/2010/03/28/how-to-return-more-than-one-value-or-multi-value-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Output XML using PHP from MySQL database</title>
		<link>http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/</link>
		<comments>http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 05:24:15 +0000</pubDate>
		<dc:creator>Thurein</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.thetechspace.com/?p=279</guid>
		<description><![CDATA[Firstly, Let me talk about this post. If your advance level php programmer, this is a piece of cake for you. I would like to say this post for beginner level. It would be a little difficult for a beginner. You may need xml output when you want to integrate with flash and MySQL records [...]]]></description>
			<content:encoded><![CDATA[<p>Firstly, Let me talk about this post. If your advance level php programmer, this is a piece of cake for you. I would like to say this post for beginner level. It would be a little difficult for a beginner. You may need xml output when you want to integrate with flash and MySQL records such as photo gallery, playlist for flash mp3 player, RSS Feeds, and so on.</p>
<p><span id="more-279"></span>I would like to show you an example to create xml playlist. So you can use this in flash mp3 player like JW Player. I have created songs table in my database. songs_id, album_id, songs_title and songs_link fields are included in this table.</p>
<p>In PHP file :</p>
<pre class="brush:php">
&lt;?php
 header('Content-type: text/xml');
 $db_host = &quot;localhost&quot; ; // MySQL Host
 $db_user = &quot;root&quot; ;    // Database Username
 $db_password = &quot;&quot; ; // Database Password
 $db_name = &quot;music&quot; ; // Database Name

 $db_link = mysql_connect(&quot;$db_host&quot;,&quot;$db_user&quot;,&quot;$db_password&quot;);
 mysql_select_db($db_name, $db_link);

?&gt;
 &lt;playlist version=&quot;1&quot; xmlns=&quot;http://xspf.org/ns/0/&quot;&gt;
 &lt;trackList&gt;
 &lt;?php
 $album_id = $_GET[aid];
 $songs = &quot;SELECT * From songs WHERE album_id='$album_id' ORDER BY song_title ASC&quot;;
 $songs_list = mysql_query( $songs, $db_link );
 $songs_total = mysql_num_rows( $songs_list );
 if( $songs_total == 0 )    {    exit;    }
 for( $f = 0; $f &lt; $songs_total; $f++ )
 {
 $each = mysql_fetch_assoc( $songs_list );
 ?&gt;
 &lt;track&gt;
 &lt;title&gt;&lt;?=$each['song_title']?&gt;&lt;/title&gt;
 &lt;location&gt;http://www.yourdomain.com/&lt;?=$each['song_link']?&gt;&lt;/location&gt;
 &lt;/track&gt;
 &lt;?php

 } // End of loop

 ?&gt;
 &lt;/trackList&gt;
 &lt;/playlist&gt;
</pre>
<p>Then you can use call this file with album id like <strong>xml.php?aid=10</strong>.</p>
<h3><a href="http://www.thetechspace.com/?download=php_xml_output" target="_blank">Download Source</a> ( size 745 B)</h3>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/&amp;title=Output+XML+using+PHP+from+MySQL+database" rel="" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/&amp;title=Output+XML+using+PHP+from+MySQL+database" rel="" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/&amp;title=Output+XML+using+PHP+from+MySQL+database" rel="" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/" rel="" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/&amp;t=Output+XML+using+PHP+from+MySQL+database" rel="" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Output+XML+using+PHP+from+MySQL+database+-+http://tinyurl.com/ylzsfru+(via+@lit_tiger)&amp;source=shareaholic" rel="" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/&amp;title=Output+XML+using+PHP+from+MySQL+database" rel="" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/&amp;imageurl=" rel="" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="sexy-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/&amp;title=Output+XML+using+PHP+from+MySQL+database" rel="" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetechspace.com/2009/11/14/output-xml-using-php-from-mysql-database/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Pagination</title>
		<link>http://www.thetechspace.com/2009/11/11/php-pagination/</link>
		<comments>http://www.thetechspace.com/2009/11/11/php-pagination/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 12:38:32 +0000</pubDate>
		<dc:creator>Thurein</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://www.thetechspace.com/?p=268</guid>
		<description><![CDATA[I have look for php pagination source. I got one very nice source code from Stranger Studio. That very nice code if your have a lot of records. You can see at sample preview.

However, this is a lot of lines in the file. If you want to put into a lot of pages, all of [...]]]></description>
			<content:encoded><![CDATA[<p>I have look for php pagination source. I got one very nice source code from <a href="http://www.strangerstudios.com/sandbox/pagination/diggstyle.php">Stranger Studio</a>. That very nice code if your have a lot of records. You can see at sample preview.</p>
<p style="text-align: center;"><img class="size-full wp-image-269 aligncenter" title="PHP Pagination" src="http://www.thetechspace.com/wp-content/uploads/2009/11/php_pagination.jpg" alt="PHP Pagination" width="457" height="33" /></p>
<p>However, this is a lot of lines in the file. If you want to put into a lot of pages, all of code you need to put into those pages. We have to take care about this. That&#8217;s while I have changed to class and functions. That&#8217;s very easy to use. I will share it back.</p>
<p><span id="more-268"></span></p>
<p>Firstly I have created class and function in the <strong>paganition.php</strong> file.</p>
<p>For usage :</p>
<pre class="brush:php">

require_once('pagination.php');
 $sql = 'SELECT * FROM contact';
 $page_name = &quot;page.php&quot;;

 //  pagination($query, $adjacents, $row_per_page, $page_name)
 $pager = new pagination($sql, 3, 20, $page_name );
 $rs = $pager-&gt;paginate();

 while($each = mysql_fetch_assoc($rs))
 {
 // Your Loop Here
 echo $each[name];
 }

 // Pages Navagation
 echo $pager-&gt;pages();
</pre>
<p>So, Page links will be come like &#8220;<strong>pagename.php?page=</strong>&#8221; . If you would like to use with <strong>.htaccess</strong> some think like http://www.yourdomain.com/content/page/page_number , you can easily to change at <strong>pagination.php</strong> . Find, &#8220;<strong>?page=</strong>&#8221; and replace with &#8220;/&#8221; . Then, you can use at page name like</p>
<pre class="brush:php">

$page_name = &quot;http://www.yourdomain.com/content/page&quot;;
</pre>
<p>In CSS.</p>
<pre class="brush:css">

div.pagination {
 padding: 3px;
 margin: 3px;
}

div.pagination a {
 padding: 2px 5px 2px 5px;
 margin: 2px;
 border: 1px solid #AAAADD;

 text-decoration: none; /* no underline */
 color: #000099;
}

div.pagination a:hover, div.pagination a:active {
 border: 1px solid #000099;

 color: #000;
}

div.pagination span.current {
 padding: 2px 5px 2px 5px;
 margin: 2px;
 border: 1px solid #000099;

 font-weight: bold;
 background-color: #000099;
 color: #FFF;
}
div.pagination span.disabled {
 padding: 2px 5px 2px 5px;
 margin: 2px;
 border: 1px solid #EEE;

 color: #DDD;
}
</pre>
<h3><a href="http://www.thetechspace.com/?download=php_pagination" target="_blank">Download Source</a> ( size 2.6 kB)</h3>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://www.thetechspace.com/2009/11/11/php-pagination/&amp;title=PHP+Pagination" rel="" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.thetechspace.com/2009/11/11/php-pagination/&amp;title=PHP+Pagination" rel="" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.thetechspace.com/2009/11/11/php-pagination/&amp;title=PHP+Pagination" rel="" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.thetechspace.com/2009/11/11/php-pagination/" rel="" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.thetechspace.com/2009/11/11/php-pagination/&amp;t=PHP+Pagination" rel="" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=PHP+Pagination+-+http://tinyurl.com/ybgsac6+(via+@lit_tiger)&amp;source=shareaholic" rel="" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.thetechspace.com/2009/11/11/php-pagination/&amp;title=PHP+Pagination" rel="" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.thetechspace.com/2009/11/11/php-pagination/&amp;imageurl=" rel="" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="sexy-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.thetechspace.com/2009/11/11/php-pagination/&amp;title=PHP+Pagination" rel="" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetechspace.com/2009/11/11/php-pagination/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to parse xml in php?</title>
		<link>http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/</link>
		<comments>http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 08:33:46 +0000</pubDate>
		<dc:creator>Thurein</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.thetechspace.com/?p=256</guid>
		<description><![CDATA[When I started and learn php programming language. I have wanted to get data from xml file and read with php. I searched with Google. I got a lot of source codes. Some of codes are working in my local machine but when I upload and test it. It doesn&#8217;t work. I have found some [...]]]></description>
			<content:encoded><![CDATA[<p>When I started and learn php programming language. I have wanted to get data from xml file and read with php. I searched with Google. I got a lot of source codes. Some of codes are working in my local machine but when I upload and test it. It doesn&#8217;t work. I have found some codes are work with almost all of server. I will share it back.</p>
<p><span id="more-256"></span>Firstly, I have created example xml file as songs.xml like :</p>
<pre class="brush:xml">

&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;

&lt;currentsongs&gt;
&lt;song&gt;
&lt;title&gt;Song Title One&lt;/title&gt;
&lt;artist&gt;artist name&lt;/artist&gt;

&lt;/song&gt;

&lt;song&gt;
&lt;title&gt;Song Title Two&lt;/title&gt;
&lt;artist&gt;Sec artist name&lt;/artist&gt;

&lt;/song&gt;
&lt;/currentsongs&gt;
</pre>
<p>Then in php file :</p>
<pre class="brush:php">
&lt;?php

$objDOM = new DOMDocument();
$objDOM-&gt;load("songs.xml"); //make sure path is correct

$songs = $objDOM-&gt;getElementsByTagName("song");

foreach( $songs as $value )
{
$title = $value-&gt;getElementsByTagName("title");
$song_title  = $title-&gt;item(0)-&gt;nodeValue;

$artist = $value-&gt;getElementsByTagName("artist");
$artist_name  = $artist-&gt;item(0)-&gt;nodeValue;

echo "$song_title - $artist_name &lt;br&gt;";
}

?&gt;
</pre>
<h3><a href="http://www.thetechspace.com/?download=php_xml_read" target="_blank">Download Source</a> ( size 868 B)</h3>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://delicious.com/post?url=http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/&amp;title=How+to+parse+xml+in+php%3F" rel="" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/&amp;title=How+to+parse+xml+in+php%3F" rel="" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/&amp;title=How+to+parse+xml+in+php%3F" rel="" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/" rel="" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/&amp;t=How+to+parse+xml+in+php%3F" rel="" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=How+to+parse+xml+in+php%3F+-+http://tinyurl.com/yl4cp5g+(via+@lit_tiger)&amp;source=shareaholic" rel="" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/&amp;title=How+to+parse+xml+in+php%3F" rel="" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/&amp;imageurl=" rel="" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="sexy-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/&amp;title=How+to+parse+xml+in+php%3F" rel="" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.thetechspace.com/2009/11/05/how-to-parse-xml-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
