<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Things i learn and wanna share</title>
	<atom:link href="http://me2learn.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://me2learn.wordpress.com</link>
	<description>thnx 4 stopping in my blog, Noor</description>
	<lastBuildDate>Fri, 30 Jan 2009 12:38:14 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='me2learn.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/304b0b2acb968d2d9dbb7b6e8aa711fb?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Things i learn and wanna share</title>
		<link>http://me2learn.wordpress.com</link>
	</image>
			<item>
		<title>Connect PHP with Oracle database</title>
		<link>http://me2learn.wordpress.com/2008/10/18/connect-php-with-oracle-database/</link>
		<comments>http://me2learn.wordpress.com/2008/10/18/connect-php-with-oracle-database/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 15:57:53 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[PHP and Oracle database]]></category>
		<category><![CDATA[apache server]]></category>
		<category><![CDATA[Connect Oracle 10g with PHP]]></category>
		<category><![CDATA[how to connect Oracle database using PHP]]></category>
		<category><![CDATA[PHP connected to Oracle]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=380</guid>
		<description><![CDATA[I spent the last four days looking for the correct way to Connect Apache server (PHP) with Oracle database, unfortunatly I didn&#8217;t find any complete article.So in this blog, I&#8217;m giving my expernce to connect &#8216;em 2geth
1. Install Apache server: 
I make this step in a seprated blog page, plz check it from this link:Install [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=380&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I spent the last four days looking for the correct way to Connect Apache server (PHP) with Oracle database, unfortunatly I didn&#8217;t find any complete article.So in this blog, I&#8217;m giving my expernce to connect &#8216;em 2geth</p>
<p><span style="text-decoration:underline;"><strong><em>1. Install Apache server: </em></strong></span></p>
<p>I make this step in a seprated blog page, plz check it from this link:<a href="../2008/10/18/install-apache-http-server/">Install Apache HTTP server</a></p>
<p><strong><em><span style="text-decoration:underline;">2. Extract the PHP zip folder:</span></em></strong></p>
<p><!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--> <!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--></p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">1. Unzip the PHP file into c:\php</p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">2. Copy all the files with the .dll extension to C:\WINDOS\system</p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">3. Copy php5apache2.dll to C:\Apache\Apache2\modules</p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;"><strong><em><span style="text-decoration:underline;"><br />
</span></em></strong></p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><strong><em><span style="text-decoration:underline;">3. Copy the file php.ini-recommended and then edit it:</span></em></strong></p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><strong><em></em></strong><!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--></p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><strong></strong></p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">1. Open C:\php then copy the file php.ini-recommended to C:\WINDOWS</p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">2. Rename it to be php.ini then open it with text editor</p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">3. Set the doc_root to be: doc_root = c:\apache\apache2\htdocs</p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">4. Set the extension_dir to: extension_dir = &#8220;C:\php\ext&#8221;</p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">5. Uncomment (Remove the semicolon &#8220;;&#8221; from the beginning of the line) this line:</p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">session.save_path = &#8220;c:/temp&#8221;</p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">6. Uncomment the line: <span> </span>extension=php_oci8.dll</p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">
<p><strong><em><span style="text-decoration:underline;">4.Edit the http.conf file:</span></em></strong></p>
<p><!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	text-align:right; 	mso-pagination:widow-orphan; 	direction:rtl; 	unicode-bidi:embed; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:568155993; 	mso-list-type:hybrid; 	mso-list-template-ids:1466864234 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--></p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;text-indent:-.25in;direction:ltr;unicode-bidi:embed;padding-left:30px;"><!--[if !supportLists]--><span>1.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:&quot;"> </span></span><!--[endif]--><span dir="ltr">Open the httpd file using any text editor, which exist on the path </span></p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;"><span> </span>C:\Apache\Apache2\conf</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;text-indent:-.25in;direction:ltr;unicode-bidi:embed;padding-left:30px;"><!--[if !supportLists]--><span>2.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:&quot;"> </span></span><!--[endif]--><span dir="ltr">Find the line AllowOverride None and change the None value to be All</span></p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;text-indent:-.25in;direction:ltr;unicode-bidi:embed;padding-left:30px;"><!--[if !supportLists]--><span>3.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:&quot;"> </span></span><!--[endif]--><span dir="ltr">Look for the line DirectoryIndex index.html index.html.var and replace it with this line: DirectoryIndex index.html index.html.var index.php</span></p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;text-indent:-.25in;direction:ltr;unicode-bidi:embed;padding-left:30px;"><!--[if !supportLists]--><span>4.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:&quot;"> </span></span><!--[endif]--><span dir="ltr">Search for a section that has a lot of AddType commands, then added this line: AddType application/x-httpd-php .php so u<span> </span>have a total of 3 AddType command.</span></p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;text-indent:-.25in;direction:ltr;unicode-bidi:embed;padding-left:30px;"><!--[if !supportLists]--><span>5.<span style="font-style:normal;font-variant:normal;font-weight:normal;font-size:7pt;line-height:normal;font-family:&quot;"> </span></span><!--[endif]--><span dir="ltr">Search for a section has many Loads and add this line to it: </span></p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;"><span> </span>LoadModule php5_module modules/php5apache2.dll</p>
<p><a href="http://me2learn.files.wordpress.com/2008/10/app11.jpg"><img class="aligncenter size-full wp-image-381" title="app11" src="http://me2learn.files.wordpress.com/2008/10/app11.jpg?w=460&#038;h=263" alt="" width="460" height="263" /></a></p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><strong><em><span style="text-decoration:underline;">5.Restart the Apache and the oracle database:</span></em></strong></p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">1. <!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	text-align:right; 	mso-pagination:widow-orphan; 	direction:rtl; 	unicode-bidi:embed; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:994145615; 	mso-list-type:hybrid; 	mso-list-template-ids:-442455874 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--> Restart the apache server using the cmd command (U can do it from      the services but using the cmd has the advantage of showing errors while      restarting the apache if there is any)</p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;"><!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	text-align:right; 	mso-pagination:widow-orphan; 	direction:rtl; 	unicode-bidi:embed; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--></p>
<blockquote>
<ul>
<li><span> </span>Open start -&gt; run -&gt; cmd -&gt; cd c:\apache\apache2\bin<span> </span>(press enter)</li>
<li> The write apache –k restart (Press enter)</li>
</ul>
</blockquote>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;"><a href="http://me2learn.files.wordpress.com/2008/10/app12.jpg"><img class="aligncenter size-full wp-image-382" title="app12" src="http://me2learn.files.wordpress.com/2008/10/app12.jpg?w=460&#038;h=232" alt="" width="460" height="232" /></a></p>
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;"><!--[if !mso]&gt; &lt;!  v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} --> <!--[endif]--><!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	text-align:right; 	mso-pagination:widow-orphan; 	direction:rtl; 	unicode-bidi:embed; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:936984248; 	mso-list-type:hybrid; 	mso-list-template-ids:-1635472612 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 	{mso-level-start-at:5; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} @list l1 	{mso-list-id:994145615; 	mso-list-type:hybrid; 	mso-list-template-ids:-442455874 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l1:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --></p>
<p style="padding-left:30px;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;"><!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]-->2.<!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	text-align:right; 	mso-pagination:widow-orphan; 	direction:rtl; 	unicode-bidi:embed; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:994145615; 	mso-list-type:hybrid; 	mso-list-template-ids:-442455874 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--> Restart the Oracle database</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">Open control panerl -&gt; administrative tools -&gt; services -&gt; the restart all the services starting with Oracle</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;"><strong><em><span style="text-decoration:underline;">6. Test the connection: </span></em></strong></p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;">
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">1. <!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	text-align:right; 	mso-pagination:widow-orphan; 	direction:rtl; 	unicode-bidi:embed; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:1112553439; 	mso-list-type:hybrid; 	mso-list-template-ids:1222651308 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]-->To make the basic connection you need some information from the tnsnames.ora      file, so follow the link C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN Then open it</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;">
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">2. <!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	text-align:right; 	mso-pagination:widow-orphan; 	direction:rtl; 	unicode-bidi:embed; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:1112553439; 	mso-list-type:hybrid; 	mso-list-template-ids:1222651308 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--> Open textpad page or use any text editor you want the past this      code:</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;"><!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--><!--[endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	text-align:right; 	mso-pagination:widow-orphan; 	direction:rtl; 	unicode-bidi:embed; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--></p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:60px;">&lt;?php</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:60px;">$db = &#8220;(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = <em>192.168.1.34</em>)(PORT = 1521)))(CONNECT_DATA=(SID=<em>orcl</em>)))&#8221; ;</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:60px;">if ($c=OCILogon(&#8220;system&#8221;, &#8220;<em>your database password</em>&#8220;, $db)) {</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:60px;">echo &#8220;Successfully connected to Oracle.\n&#8221;;</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:60px;">OCILogoff($c);</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:60px;">} else {</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:60px;">$err = OCIError();</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:60px;">echo &#8220;Connection failed.&#8221; . $err[text];</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:60px;">}</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:60px;"><span dir="rtl" lang="AR-SA"> </span></p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:60px;">?&gt;</p>
<p style="padding-left:60px;"><!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--><br />
Where the HOST is taken from your tnsnames.ora file and SID value is equal to your database name Then save the file with the name test.php</p>
<p style="padding-left:60px;">3. <!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--> Open web browser page and type on the title: <a href="http://localhost/test.php">http://localhost/test.php</a></p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">If it all worked well you will get white page with the result:</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;padding-left:30px;">Successfully connected to Oracle.</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;">
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;">
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;"><strong><em><span style="text-decoration:underline;">NOTE:</span></em></strong> Recommended links to download the software&#8217;s:</p>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;">
<table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><span class="bodycopy">Software</span></p>
</td>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><span class="bodycopy">Version</span></p>
</td>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><span class="bodycopy">URL</span></p>
</td>
</tr>
<tr>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><span class="bodycopy">Oracle Database 10</span><em>g</em><span class="bodycopy"> Express Edition</span></p>
</td>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><span class="bodycopy">10.2</span></p>
</td>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><a href="http://www.oracle.com/technology/products/database/xe/index.html">http://www.oracle.com/technology/products/database/xe/</a></p>
</td>
</tr>
<tr>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><span class="bodycopy">Apache HTTP Server</span></p>
</td>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><span class="bodycopy">2.0.58</span></p>
</td>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><a href="http://httpd.apache.org/download.cgi">http://httpd.apache.org/download.cgi</a></p>
</td>
</tr>
<tr>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><span class="bodycopy">PHP Hypertext Processor</span></p>
</td>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><span class="bodycopy">5.1.3</span></p>
</td>
<td style="padding:2.25pt;">
<p class="MsoNormal" style="text-align:left;direction:ltr;unicode-bidi:embed;"><a href="http://www.php.net/downloads.php">http://www.php.net/downloads.php</a></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;">
<p class="MsoNormal" style="margin-left:.25in;text-align:left;direction:ltr;unicode-bidi:embed;">
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/380/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/380/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/380/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=380&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/10/18/connect-php-with-oracle-database/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app11.jpg" medium="image">
			<media:title type="html">app11</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app12.jpg" medium="image">
			<media:title type="html">app12</media:title>
		</media:content>
	</item>
		<item>
		<title>Install Apache HTTP server:</title>
		<link>http://me2learn.wordpress.com/2008/10/18/install-apache-http-server/</link>
		<comments>http://me2learn.wordpress.com/2008/10/18/install-apache-http-server/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 15:18:36 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[PHP and Oracle database]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[apache server]]></category>
		<category><![CDATA[install apache]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=365</guid>
		<description><![CDATA[To install the Apache server, it&#8217;s straight forward &#8230;
Just follow the pictures  










       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=365&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>To install the Apache server, it&#8217;s straight forward &#8230;</p>
<p>Just follow the pictures <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align:center;"><a href="http://me2learn.files.wordpress.com/2008/10/app1.jpg"><img class="size-full wp-image-366 aligncenter" title="app1" src="http://me2learn.files.wordpress.com/2008/10/app1.jpg?w=460&#038;h=354" alt="" width="460" height="354" /></a></p>
<p><a href="http://me2learn.files.wordpress.com/2008/10/app2.jpg"><img class="aligncenter size-full wp-image-367" title="app2" src="http://me2learn.files.wordpress.com/2008/10/app2.jpg?w=460&#038;h=354" alt="" width="460" height="354" /></a></p>
<p><a href="http://me2learn.files.wordpress.com/2008/10/app3.jpg"><img class="aligncenter size-full wp-image-368" title="app3" src="http://me2learn.files.wordpress.com/2008/10/app3.jpg?w=460&#038;h=354" alt="" width="460" height="354" /></a></p>
<p><a href="http://me2learn.files.wordpress.com/2008/10/app4.jpg"><img class="aligncenter size-full wp-image-369" title="app4" src="http://me2learn.files.wordpress.com/2008/10/app4.jpg?w=460&#038;h=354" alt="" width="460" height="354" /></a></p>
<p><a href="http://me2learn.files.wordpress.com/2008/10/app5.jpg"><img class="aligncenter size-full wp-image-370" title="app5" src="http://me2learn.files.wordpress.com/2008/10/app5.jpg?w=460&#038;h=354" alt="" width="460" height="354" /></a></p>
<p><a href="http://me2learn.files.wordpress.com/2008/10/app6.jpg"><img class="aligncenter size-full wp-image-371" title="app6" src="http://me2learn.files.wordpress.com/2008/10/app6.jpg?w=460&#038;h=354" alt="" width="460" height="354" /></a></p>
<p><a href="http://me2learn.files.wordpress.com/2008/10/app7.jpg"><img class="aligncenter size-full wp-image-372" title="app7" src="http://me2learn.files.wordpress.com/2008/10/app7.jpg?w=460&#038;h=354" alt="" width="460" height="354" /></a></p>
<p><a href="http://me2learn.files.wordpress.com/2008/10/app8.jpg"><img class="aligncenter size-full wp-image-373" title="app8" src="http://me2learn.files.wordpress.com/2008/10/app8.jpg?w=460&#038;h=354" alt="" width="460" height="354" /></a></p>
<p><a href="http://me2learn.files.wordpress.com/2008/10/app9.jpg"><img class="aligncenter size-full wp-image-374" title="app9" src="http://me2learn.files.wordpress.com/2008/10/app9.jpg?w=460&#038;h=354" alt="" width="460" height="354" /></a></p>
<p><a href="http://me2learn.files.wordpress.com/2008/10/app10.jpg"><img class="aligncenter size-full wp-image-375" title="app10" src="http://me2learn.files.wordpress.com/2008/10/app10.jpg?w=460&#038;h=354" alt="" width="460" height="354" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/365/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/365/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/365/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=365&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/10/18/install-apache-http-server/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app1.jpg" medium="image">
			<media:title type="html">app1</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app2.jpg" medium="image">
			<media:title type="html">app2</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app3.jpg" medium="image">
			<media:title type="html">app3</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app4.jpg" medium="image">
			<media:title type="html">app4</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app5.jpg" medium="image">
			<media:title type="html">app5</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app6.jpg" medium="image">
			<media:title type="html">app6</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app7.jpg" medium="image">
			<media:title type="html">app7</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app8.jpg" medium="image">
			<media:title type="html">app8</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app9.jpg" medium="image">
			<media:title type="html">app9</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/app10.jpg" medium="image">
			<media:title type="html">app10</media:title>
		</media:content>
	</item>
		<item>
		<title>checking the information from HTML forms</title>
		<link>http://me2learn.wordpress.com/2008/10/01/checking-the-information-from-html-forms/</link>
		<comments>http://me2learn.wordpress.com/2008/10/01/checking-the-information-from-html-forms/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 18:57:43 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[Common PHP Applications]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Checking for empty fields]]></category>
		<category><![CDATA[Checking for specific format]]></category>
		<category><![CDATA[checking the data entered by user]]></category>
		<category><![CDATA[Cleaning information]]></category>
		<category><![CDATA[enable tags in PHP]]></category>
		<category><![CDATA[how to disable tags entered by user]]></category>
		<category><![CDATA[htmlspecialchars]]></category>
		<category><![CDATA[remove HTML special characters entered by user]]></category>
		<category><![CDATA[remove tags from forms data]]></category>
		<category><![CDATA[strip_tags]]></category>
		<category><![CDATA[trim]]></category>
		<category><![CDATA[Using regular expressions to check user input]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=358</guid>
		<description><![CDATA[b4 u use the values in your script, u need to check the variables to make sure they contain what u expect &#8216;em to contain! Thus never trust info from user.
Checking for empty fields:
u can require the user to enter info in a field and check when the user didn&#8217;t and let him back to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=358&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>b4 u use the values in your script, u need to check the variables to make sure they contain what u expect &#8216;em to contain! Thus never trust info from user.</p>
<p><strong><span style="text-decoration:underline;">Checking for empty fields:</span></strong></p>
<p>u can require the user to enter info in a field and check when the user didn&#8217;t and let him back to re-fill that field using:</p>
<p><span style="color:#ff0000;">empty($_POST['<em>field_name</em>'])</span>;</p>
<p>this function returns true if the field is empty,,, false otherwise !</p>
<p><strong><span style="text-decoration:underline;">Checking for specific format:</span></strong></p>
<p>u can check using some built in functions like if u expect string, u can check using is_string and so on&#8230; for a table of these functions c this previous post <a title="Changing the order of statement execution" href="../2008/09/19/changing-the-order-of-statement-execution/">Changing the order of statement execution </a></p>
<p><strong><span style="text-decoration:underline;">Using regular expressions to check user input:</span></strong></p>
<p>u can aslo compare the info to a pattern to c if it matches if u care a lot about the information pattern using ereg function &#8230; for more in this ,,, check this previous post: <a title="pattern matching with regular expressions" href="../2008/09/19/pattern-matching-with-regular-expressions/">pattern matching with regular expressions</a></p>
<p><strong><span style="text-decoration:underline;">Cleaning information:</span></strong></p>
<ul>
<li>strip_tags: this function removes all tags from the text, u can keep some tags:</li>
</ul>
<p><span style="color:#ff0000;">$<em>variable_name</em> = strip_tags($_POST)['<em>field_name</em>'],&#8221;<em>&lt;tag u allow&gt; &lt;tag u allow&gt;</em>&#8220;);</span></p>
<ul>
<li>htmlspecialchars: this function changes some special characters to HTML into HTML format that allow &#8216;em to display without any special meaning</li>
</ul>
<p>Examples: &lt; become &amp;alt;</p>
<p>? become &amp;gt;</p>
<p>and &amp; become &amp;amp;</p>
<p><span style="color:#ff0000;">$<em>variable_nam</em>e= htmlspecialchars(</span><span style="color:#ff0000;">$_POST)['<em>field_name</em>']);</span></p>
<ul>
<li>trim: remove extra spaces at the beginning and the end of the field info, bcz it&#8217;s familiar that user enter spaces by mistake.</li>
</ul>
<p><span style="color:#ff0000;">$<em>variable_name</em>= trim(</span><span style="color:#ff0000;">$_POST)['<em>field_name</em>']);</span></p>
<p>Example:</p>
<p>in this example, i will use the same forms in the previous post but i will check for three fields (first name, second name and last name) not to keep blank ,,, if so &#8230; the user will be asked to re-fill &#8216;em &#8230;. if they r not blank , then it will output the same information in that example&#8230;.</p>
<p>Building the forms code:</p>
<p>&lt;br&gt;&lt;center&gt;&lt;h2&gt; Customer information &lt;/h2&gt;&lt;/center&gt;<br />
&lt;br&gt;&lt;br&gt;</p>
<p>&lt;center&gt;<br />
&lt;table border=&#8221;0&#8243;&gt;<br />
&lt;form action=&#8221;customer_info.php&#8221; method=&#8221;POST&#8221;&gt;<br />
&lt;tr&gt; &lt;td&gt; First name:&lt;/td&gt; &lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;first_name&#8221;&gt;&lt;/td&gt;&lt;/tr&gt;<br />
&lt;tr&gt; &lt;td&gt;Second name: &lt;/td&gt; &lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;second_name&#8221;&gt; &lt;/td&gt;&lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt;Last name: &lt;/td&gt; &lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;last_name&#8221;&gt;&lt;/td&gt; &lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt; Street Address:&lt;/td&gt;&lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;st_address&#8221;&gt;&lt;/td&gt; &lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt; City:&lt;/td&gt;&lt;td&gt;<br />
&lt;select name=&#8221;city&#8221;<br />
&lt;option&gt; Amman &lt;/option&gt;<br />
&lt;option&gt; Aqaba &lt;/option&gt;<br />
&lt;option&gt; Irbd &lt;/option&gt;<br />
&lt;option&gt; Zarqa &lt;/option&gt;<br />
&lt;/td&gt; &lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt;Sex: &lt;/td&gt;&lt;td&gt;<br />
&lt;input type =&#8221;radio&#8221; name=&#8221;Radio1&#8243; value= &#8220;M&#8221; &gt; Male<br />
&lt;input type =&#8221;radio&#8221; name=&#8221;Radio1&#8243; value= &#8220;F&#8221;&gt; Female<br />
&lt;/td&gt;&lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt;Your Operating system: &lt;/td&gt;&lt;td&gt;<br />
&lt;input type= &#8220;checkbox&#8221; name=&#8221;os0&#8243; value=&#8221;W&#8221;&gt; Windows<br />
&lt;input type= &#8220;checkbox&#8221; name=&#8221;os1&#8243; value=&#8221;L&#8221;&gt; Linux<br />
&lt;input type= &#8220;checkbox&#8221; name=&#8221;os2&#8243; value=&#8221;M&#8221;&gt; Mac<br />
&lt;/td&gt;&lt;/tr&gt;<br />
&lt;/table&gt;&lt;br&gt;</p>
<p>&lt;input type=&#8221;submit&#8221; value=&#8221;submit name&#8221;&gt;<br />
&lt;/form&gt;</p>
<p><strong><em><span style="text-decoration:underline;">the customer info code:</span></em></strong></p>
<p>&lt;?php</p>
<p>function set_sex(){<br />
if ($_POST[Radio1]==&#8221;M&#8221;) {<br />
$sex= &#8220;Male&#8221;;<br />
}<br />
else<br />
{<br />
$sex= &#8220;Female&#8221;;}<br />
}</p>
<p>function print_info()<br />
{</p>
<p>echo &#8220;Welcome &#8220;,$_POST['first_name'],&#8221;!&lt;br&gt;&#8221;;<br />
echo &#8220;Your second name is: &#8220;,$_POST['second_name'];<br />
echo &#8220;&lt;br&gt;Your last name is: &#8220;,$_POST['last_name'];<br />
echo &#8220;&lt;br&gt;&#8221;;<br />
echo &#8220;you are &#8220;, $sex;<br />
echo &#8221; living in: &#8220;, $_POST[city];<br />
echo &#8220;  in the &#8220;, $_POST[st_address],&#8221; Street&#8221;;<br />
echo &#8220;&lt;br&gt;and your operating systems are: &lt;br&gt;&#8221;;</p>
<p>if (isset($_POST['os0'])) {<br />
echo &#8220;Windows&lt;br&gt;&#8221;;<br />
}</p>
<p>if (isset($_POST['os1'])) {<br />
echo &#8220;Linux&lt;br&gt;&#8221;;<br />
}</p>
<p>if (isset($_POST['os2'])) {<br />
echo &#8220;Mac&lt;br&gt;&#8221;;<br />
}<br />
return;<br />
}</p>
<p>function blank_check(){<br />
if (empty($_POST['first_name']))<br />
{<br />
echo &#8220;You didn&#8217;t enter your first name! &lt;br&gt;&#8221;;<br />
$blank_check_var = TRUE;<br />
}</p>
<p>if (empty($_POST['second_name']))<br />
{<br />
echo &#8220;You didn&#8217;t enter your second name! &lt;br&gt;&#8221;;<br />
$blank_check_var = TRUE;<br />
}</p>
<p>if (empty($_POST['last_name']))<br />
{<br />
echo &#8220;You didn&#8217;t enter your last name! &lt;br&gt;&#8221;;<br />
$blank_check_var = TRUE;<br />
}</p>
<p>return $blank_check_var;</p>
<p>}</p>
<p>//main<br />
set_sex();<br />
$check_var= blank_check();<br />
if (!$check_var){<br />
print_info();<br />
}</p>
<p>?&gt;</p>
<p>The output after leaving the first name blank is:</p>
<p>You didn&#8217;t enter your first name!</p>
<p>The output after leaving the first and second name blank is:</p>
<p>You didn&#8217;t enter your first name!<br />
You didn&#8217;t enter your second name!</p>
<p>The output after leaving the first, second and last name blank is:</p>
<p>You didn&#8217;t enter your first name!<br />
You didn&#8217;t enter your second name!<br />
You didn&#8217;t enter your last name!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/358/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=358&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/10/01/checking-the-information-from-html-forms/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>
	</item>
		<item>
		<title>Receiving the information from HTML forms</title>
		<link>http://me2learn.wordpress.com/2008/10/01/receiving-the-information-from-html-forms/</link>
		<comments>http://me2learn.wordpress.com/2008/10/01/receiving-the-information-from-html-forms/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 13:42:55 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[Common PHP Applications]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[check box]]></category>
		<category><![CDATA[difference between GET and POST]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[receive the information from check box]]></category>
		<category><![CDATA[Receive the information from HTML forms]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=354</guid>
		<description><![CDATA[The forms data r available at PHP built in array. As said earlier there two methods to send the data: POST and GET, so information from any form uses the method POST is available in the built-in array $_POST with the key for each field with it&#8217;s name! and information from any form uses the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=354&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The forms data r available at PHP built in array. As said earlier there two methods to send the data: POST and GET, so information from any form uses the method POST is available in the built-in array $_POST with the key for each field with it&#8217;s name! and information from any form uses the method GET is found in the array $_GET, and the key for each field is it&#8217;s name &#8230;</p>
<p>The information that user select from drop down menu or radio buttons r similarly available for use, but the situation is a lil different while using check boxes bcz the user can check more than one box, the information is in multidimentional array ,,,, but i think there is an easier wayL when u create check box bottons, name each buton a unique name, and get it from 1D array, it will be faster and easier to code &#8230; remember no one can c ur code ,,, every one will c the effect of ur code, so write it in the easiest way 4 u :p <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong><span style="text-decoration:underline;">What is the difference between POST and GET:</span></strong></p>
<ul>
<li>Get method: The form data is passed by adding it to the URL. The advantages for this method: it&#8217;s simple and fast but the disadvantages r less data to be passed and less secure (since the information r displayed in the browser).</li>
<li>Post method: The form data is passed as a package in a separate communication with the processing script. The advantages: unlimited information to be passed and more secure and the disadvantage is the overhead which slows the speed.</li>
</ul>
<p>Example:</p>
<p>&lt;br&gt;&lt;center&gt;&lt;h2&gt; Customer information &lt;/h2&gt;&lt;/center&gt;<br />
&lt;br&gt;&lt;br&gt;</p>
<p>&lt;center&gt;<br />
&lt;table border=&#8221;0&#8243;&gt;<br />
&lt;form action=&#8221;customer_info.php&#8221; method=&#8221;POST&#8221;&gt;<br />
&lt;tr&gt; &lt;td&gt; First name:&lt;/td&gt; &lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;first_name&#8221; value=&#8221;enter ur first name plz&#8221;&gt;&lt;/td&gt;&lt;/tr&gt;<br />
&lt;tr&gt; &lt;td&gt;Second name: &lt;/td&gt; &lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;second_name&#8221; value=&#8221;enter ur second name plz&#8221;&gt; &lt;/td&gt;&lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt;Last name: &lt;/td&gt; &lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;last_name&#8221; value=&#8221;enter ur last name plz&#8221;&gt;&lt;/td&gt; &lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt; Street Address:&lt;/td&gt;&lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;st_address&#8221; value=&#8221;enter ur st address plz&#8221;&gt;&lt;/td&gt; &lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt; City:&lt;/td&gt;&lt;td&gt;<br />
&lt;select name=&#8221;city&#8221;<br />
&lt;option&gt; Amman &lt;/option&gt;<br />
&lt;option&gt; Aqaba &lt;/option&gt;<br />
&lt;option&gt; Irbd &lt;/option&gt;<br />
&lt;option&gt; Zarqa &lt;/option&gt;<br />
&lt;/td&gt; &lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt;Sex: &lt;/td&gt;&lt;td&gt;<br />
&lt;input type =&#8221;radio&#8221; name=&#8221;Radio1&#8243; value= &#8220;M&#8221; &gt; Male<br />
&lt;input type =&#8221;radio&#8221; name=&#8221;Radio1&#8243; value= &#8220;F&#8221;&gt; Female<br />
&lt;/td&gt;&lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt;Your Operating system: &lt;/td&gt;&lt;td&gt;<br />
&lt;input type= &#8220;checkbox&#8221; name=&#8221;os0&#8243; value=&#8221;W&#8221;&gt; Windows<br />
&lt;input type= &#8220;checkbox&#8221; name=&#8221;os1&#8243; value=&#8221;L&#8221;&gt; Linux<br />
&lt;input type= &#8220;checkbox&#8221; name=&#8221;os2&#8243; value=&#8221;M&#8221;&gt; Mac<br />
&lt;/td&gt;&lt;/tr&gt;<br />
&lt;/table&gt;&lt;br&gt;</p>
<p>&lt;input type=&#8221;submit&#8221; value=&#8221;submit name&#8221;&gt;<br />
&lt;/form&gt;</p>
<p><strong><em><span style="text-decoration:underline;">and now &#8230;. the customer_info.php code:</span></em></strong></p>
<p>&lt;?php</p>
<p>if ($_POST[Radio1]==&#8221;M&#8221;) {<br />
$sex= &#8220;Male&#8221;;<br />
}<br />
else<br />
{<br />
$sex= &#8220;Female&#8221;;}</p>
<p>echo &#8220;Welcome &#8220;,$_POST['first_name'],&#8221;!&lt;br&gt;&#8221;;<br />
echo &#8220;Your second name is: &#8220;,$_POST['second_name'];<br />
echo &#8220;&lt;br&gt;Your last name is: &#8220;,$_POST['last_name'];<br />
echo &#8220;&lt;br&gt;&#8221;;<br />
echo &#8220;you are &#8220;, $sex;<br />
echo &#8221; living in: &#8220;, $_POST[city];<br />
echo &#8220;  in the &#8220;, $_POST[st_address],&#8221; Street&#8221;;<br />
echo &#8220;&lt;br&gt;and your operating systems are: &lt;br&gt;&#8221;;</p>
<p>if (isset($_POST['os0'])) {<br />
echo &#8220;Windows&lt;br&gt;&#8221;;<br />
}</p>
<p>if (isset($_POST['os1'])) {<br />
echo &#8220;Linux&lt;br&gt;&#8221;;<br />
}</p>
<p>if (isset($_POST['os2'])) {<br />
echo &#8220;Mac&lt;br&gt;&#8221;;<br />
}</p>
<p>?&gt;</p>
<p>The output:</p>
<p><a href="http://me2learn.files.wordpress.com/2008/10/customer_1.jpg"><img class="aligncenter size-full wp-image-355" title="customer_1" src="http://me2learn.files.wordpress.com/2008/10/customer_1.jpg?w=390&#038;h=333" alt="" width="390" height="333" /></a></p>
<p>and after clicking the submit name button u will c the following page:</p>
<p>Welcome Noor!<br />
Your second name is: A<br />
Your last name is: Adiga<br />
you are Female living in: Aqaba  in the Abc ST Street<br />
and your operating systems are:<br />
Windows</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/354/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=354&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/10/01/receiving-the-information-from-html-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/10/customer_1.jpg" medium="image">
			<media:title type="html">customer_1</media:title>
		</media:content>
	</item>
		<item>
		<title>working with HTML forms</title>
		<link>http://me2learn.wordpress.com/2008/09/29/working-with-html-forms/</link>
		<comments>http://me2learn.wordpress.com/2008/09/29/working-with-html-forms/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 14:12:17 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[Common PHP Applications]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Adding check boxes]]></category>
		<category><![CDATA[Adding Radio Buttons]]></category>
		<category><![CDATA[Adding selection list]]></category>
		<category><![CDATA[create HTML forms]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=349</guid>
		<description><![CDATA[For a web page tp be active, it must collect information from the user. which is done using HTML forms.
Displaying HTML forms:
there is two ways to do that, u can write the HTML code directly or inside the echo statement, which gives the browser html sentences.
&#60;form action = &#8220;page to open after click submit.php&#8221; method= [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=349&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>For a web page tp be active, it must collect information from the user. which is done using HTML forms.</p>
<p><span style="text-decoration:underline;"><strong>Displaying HTML forms:</strong></span></p>
<p>there is two ways to do that, u can write the HTML code directly or inside the echo statement, which gives the browser html sentences.</p>
<p><span style="color:#ff0000;">&lt;form action = &#8220;<em>page to open after click submit.php</em>&#8221; method= &#8220;<em>POST</em>&#8221; &gt;</span></p>
<p><span style="color:#ff0000;">&lt;input type= &#8220;text&#8221; name= &#8220;<em>field name</em>&#8221; value = &#8220;<em>default value to display</em>&#8220;&gt;</span></p>
<p><span style="color:#ff0000;">&lt;input type= &#8220;text&#8221; name= &#8220;<em>field name</em>&#8221; value = &#8220;<em>default value to display</em>&#8220;&gt;</span></p>
<p><span style="color:#ff0000;">&lt;input type =&#8221;submit&#8221; value = &#8220;<em>Submit button name</em>&#8220;&gt;</span></p>
<ul>
<li>action: u write here the name of the page u want the user to go into after clicking the submit button</li>
<li>method: there r two ways of methods: POST and GET &#8230; i will talk about &#8216;em later in this blog</li>
<li>now, we start creating the fields using &lt;input type=&#8221;text&#8221; which means that the field will be text field</li>
<li>name: the name of the field, will not be displayed, just to work with while taking information from it</li>
<li>value: this value will be written inside the field box at the beginning</li>
<li>now, to make the submit button, by putting the type = &#8220;submit&#8221;</li>
<li>value: this will be the text written over the button</li>
</ul>
<p><span style="text-decoration:underline;"><strong>Adding selection list:</strong></span></p>
<p><span style="color:#ff0000;">&lt;select name=&#8221;<em>the list name</em>&#8220;&gt;</span></p>
<p><span style="color:#ff0000;">&lt;option&gt; &#8220;<em>first option</em>&#8221; &lt;/option&gt;</span></p>
<p><span style="color:#ff0000;">&lt;option&gt; &#8220;<em>second option</em>&#8221; &lt;/option&gt;</span></p>
<p><span style="color:#ff0000;">&lt;option&gt; &#8220;<em>fthird option</em>&#8221; &lt;/option&gt;</span></p>
<p><span style="color:#ff0000;">&lt;/select&gt;</span></p>
<p><strong><span style="text-decoration:underline;">Adding Radio Buttons:</span></strong></p>
<p><span style="color:#ff0000;">&lt;input type=&#8221;radio&#8221; name = &#8220;<em>radio  name</em>&#8221; value = &#8220;<em>the value to be stored while receiving the info </em>&#8220;&gt; &#8220;text to display &#8220;</span></p>
<p><span style="color:#ff0000;">&lt;input type=&#8221;radio&#8221; name = &#8220;<em>radio  name</em>&#8221; value = &#8220;<em>the value to be stored while receiving the info </em>&#8220;&gt; &#8220;text to display &#8220;</span></p>
<p>Its important to use the same name for all radio options. otherwise it won&#8217;t work probably!</p>
<p><span style="text-decoration:underline;"><strong>Adding check boxes:</strong></span></p>
<p><span style="color:#ff0000;">&lt;input type=&#8221;checkbox&#8221; name=&#8221;<em>check box name</em>&#8221; value= &#8220;<em>value to be stored</em>&#8221; &gt; &#8220;<em>text to display</em>&#8220;</span></p>
<p><span style="color:#ff0000;">&lt;input type=&#8221;checkbox&#8221; name=&#8221;<em>check box name</em>&#8221; value= &#8220;<em>value to be stored</em>&#8221; &gt; &#8220;<em>text to display</em>&#8220;</span></p>
<p>Example:</p>
<p>&lt;br&gt;&lt;center&gt;&lt;h2&gt; Customer information &lt;/h2&gt;&lt;/center&gt;<br />
&lt;br&gt;&lt;br&gt;</p>
<p>&lt;center&gt;<br />
&lt;table border=&#8221;0&#8243;&gt;<br />
&lt;form action=&#8221;customer_info.php&#8221; method=&#8221;POST&#8221;&gt;<br />
&lt;tr&gt; &lt;td&gt; First name:&lt;/td&gt; &lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;first_name&#8221; value=&#8221;enter ur first name plz&#8221;&gt;&lt;/td&gt;&lt;/tr&gt;<br />
&lt;tr&gt; &lt;td&gt;Second name: &lt;/td&gt; &lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;second_name&#8221; value=&#8221;enter ur second name plz&#8221;&gt; &lt;/td&gt;&lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt;Last name: &lt;/td&gt; &lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;last_name&#8221; value=&#8221;enter ur last name plz&#8221;&gt;&lt;/td&gt; &lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt; Street Address:&lt;/td&gt;&lt;td&gt; &lt;input type=&#8221;text&#8221; name=&#8221;st_address&#8221; value=&#8221;enter ur st address plz&#8221;&gt;&lt;/td&gt; &lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt; City:&lt;/td&gt;&lt;td&gt;<br />
&lt;select name=&#8221;city&#8221;<br />
&lt;option&gt; Amman &lt;/option&gt;<br />
&lt;option&gt; Aqaba &lt;/option&gt;<br />
&lt;option&gt; Irbd &lt;/option&gt;<br />
&lt;option&gt; Zarqa &lt;/option&gt;<br />
&lt;/td&gt; &lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt;Sex: &lt;/td&gt;&lt;td&gt;<br />
&lt;input type =&#8221;radio&#8221; name=&#8221;Radio1&#8243; value= &#8220;M&#8221; &gt; Male<br />
&lt;input type =&#8221;radio&#8221; name=&#8221;Radio1&#8243; value= &#8220;F&#8221;&gt; Female<br />
&lt;/td&gt;&lt;/tr&gt;<br />
&lt;tr&gt;&lt;td&gt;Your Operating system: &lt;/td&gt;&lt;td&gt;<br />
&lt;input type= &#8220;checkbox&#8221; name= os value=&#8221;Windows1&#8243;&gt; Windows<br />
&lt;input type= &#8220;checkbox&#8221; name= os value=&#8221;Linux1&#8243;&gt; Linux<br />
&lt;input type= &#8220;checkbox&#8221; name= os value=&#8221;Mac1&#8243;&gt; Mac<br />
&lt;/td&gt;&lt;/tr&gt;<br />
&lt;/table&gt;&lt;br&gt;</p>
<p>&lt;input type=&#8221;submit&#8221; value=&#8221;submit name&#8221;&gt;<br />
&lt;/form&gt;<br />
The output:</p>
<p><a href="http://me2learn.files.wordpress.com/2008/09/custome.jpg"><img class="aligncenter size-full wp-image-350" title="custome" src="http://me2learn.files.wordpress.com/2008/09/custome.jpg?w=426&#038;h=344" alt="" width="426" height="344" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/349/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/349/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/349/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/349/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/349/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=349&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/09/29/working-with-html-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>

		<media:content url="http://me2learn.files.wordpress.com/2008/09/custome.jpg" medium="image">
			<media:title type="html">custome</media:title>
		</media:content>
	</item>
		<item>
		<title>handling functions errors</title>
		<link>http://me2learn.wordpress.com/2008/09/24/handling-functions-errors/</link>
		<comments>http://me2learn.wordpress.com/2008/09/24/handling-functions-errors/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 12:23:34 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[Basic PHP programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[die]]></category>
		<category><![CDATA[error failuer in functions]]></category>
		<category><![CDATA[exit]]></category>
		<category><![CDATA[handling error]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=346</guid>
		<description><![CDATA[Sometimes functions fail, sad but true. ur script should anticipate any possible function failer and handle the situation like displaying ur wn message error. this can be done using die statement
function_name () or die(&#8220;ur message&#8220;);
The die statement stops the script and prints out whatever u haved entered in its message. is is when the function [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=346&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Sometimes functions fail, sad but true. ur script should anticipate any possible function failer and handle the situation like displaying ur wn message error. this can be done using die statement</p>
<p><span style="color:#ff0000;">function_name () or die(<em>&#8220;ur message</em>&#8220;);</span></p>
<p>The die statement stops the script and prints out whatever u haved entered in its message. is is when the function returns false !</p>
<p>but remeber that u should shut off the display for error messages, otherwise ur used will c 2 error messages.</p>
<p>U can also handle possible functions faileres by using the function call as condition.</p>
<p><span style="color:#ff0000;">if (!function_name(<em>$variable</em>))</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><span style="color:#ff0000;">echo &#8220;<em>ur error message here</em>&#8220;;</span></p>
<p><span style="color:#ff0000;">exit();</span></p>
<p><span style="color:#ff0000;">}</span></p>
<p>the exit statement does the same as die statement!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/346/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=346&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/09/24/handling-functions-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>
	</item>
		<item>
		<title>Passing values to a function</title>
		<link>http://me2learn.wordpress.com/2008/09/24/passing-values-to-a-function/</link>
		<comments>http://me2learn.wordpress.com/2008/09/24/passing-values-to-a-function/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 12:08:29 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[Basic PHP programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Passing values by reference]]></category>
		<category><![CDATA[using default value while passing values to functions i]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=343</guid>
		<description><![CDATA[you can pass values to a function by adding the values between parantheses when u call the function but before that u should define the values while defining the function
While passing values, make sure of the following:
1. passing the right data type:
the value passed can be any data type, including arrays and objects. A good [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=343&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>you can pass values to a function by adding the values between parantheses when u call the function but before that u should define the values while defining the function</p>
<p>While passing values, make sure of the following:</p>
<p><strong><span style="text-decoration:underline;">1. passing the right data type:</span></strong></p>
<p>the value passed can be any data type, including arrays and objects. A good practice is to check the value type before using it. especailly when u r taking these values from the user.</p>
<p>To use built-in functions that check the type, see this previous post:</p>
<p><a title="Changing the order of statement execution" href="../2008/09/19/changing-the-order-of-statement-execution/">Changing the order of statement execution</a></p>
<p><strong><span style="text-decoration:underline;">2. passing values in the correct order:</span></strong></p>
<p>when u call the function test($a,$b); using test($x,$y);</p>
<p>then $a = $x and $b = $y &#8230;. each variable will take a value in order, if u call test($y,$x);</p>
<p>then $a = $y and $b = $x ,,, which is not the same &#8230; so pay attention to the order!</p>
<p><strong><span style="text-decoration:underline;">3. passing the correct number of values:</span></strong></p>
<p>If u pass less numbers of values then the PHP will assign the missing values to be NULL and u will have a warning message.</p>
<p>if u pass many values than the function expected, it will ignore the extra values!</p>
<p>Note: u can assign default value for ur variables, so in the case that u forget to pass some values, the function will user their defaults</p>
<p><span style="color:#ff0000;">function function_name($varibale1<em>= &#8220;default value&#8221;</em>, $variable2=<em> &#8220;default value&#8221;</em>)</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><span style="color:#ff0000;">block of statements</span></p>
<p><span style="color:#ff0000;">return;<br />
</span></p>
<p><span style="color:#ff0000;">}</span></p>
<p><strong><span style="text-decoration:underline;">4. Passing values by reference:</span></strong></p>
<p>when u pass values into variables in the function definition, u pass them by value (by default), u can make as many changes as u want inside the function, but when u back from the function , the value will return to it&#8217;s previous value b4 calling the function bcz u send a copy from the variable. If u want ur changes to affect the variable pass that variable by reference (think about it as u pass a pointer) any changes inside the function will stay after exiting the function!</p>
<p>Passing by reference is used mainly when passing really large values bcz it&#8217;s much faster!</p>
<p>Example:</p>
<p>&lt;?php<br />
function welcome_by_name ($name= &#8220;Visitor&#8221;)<br />
{<br />
echo &#8220;Welcome &#8220;, $name;<br />
return;<br />
}</p>
<p>echo &#8220;Passing the name \&#8221;Noor\&#8221; to the welcome function&lt;br&gt; &#8220;;<br />
welcome_by_name(&#8220;Noor&#8221;);<br />
echo &#8220;&lt;br&gt; Using the default value while calling the function &lt;br&gt;&#8221;;<br />
welcome_by_name();</p>
<p>?&gt;</p>
<p>The output:</p>
<p>Passing the name &#8220;Noor&#8221; to the welcome function<br />
WelcomeNoor<br />
Using the default value while calling the function<br />
Welcome Visitor</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/343/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/343/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=343&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/09/24/passing-values-to-a-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating reusable code(functions)</title>
		<link>http://me2learn.wordpress.com/2008/09/24/creating-reusable-codefunctions/</link>
		<comments>http://me2learn.wordpress.com/2008/09/24/creating-reusable-codefunctions/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 11:26:10 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[Basic PHP programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Defining functions]]></category>
		<category><![CDATA[functions in PHP]]></category>
		<category><![CDATA[global variables]]></category>
		<category><![CDATA[return values in functions]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=340</guid>
		<description><![CDATA[A function is a group of PHP statements that perform a specific task, u can use the function whenever u need to perform the task.
Defining functions:
function function_name ()
{
block of statements
return;

}
The return statement stops the function and returns to the main script, it is not required but it makes the functions easier to understand.U can write [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=340&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A function is a group of PHP statements that perform a specific task, u can use the function whenever u need to perform the task.</p>
<p><strong><span style="text-decoration:underline;">Defining functions:</span></strong></p>
<p><span style="color:#ff0000;">function <em>function_name</em> ()</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><em><span style="color:#ff0000;">block of statements</span></em></p>
<p><span style="color:#ff0000;">return;<br />
</span></p>
<p><span style="color:#ff0000;">}</span></p>
<p>The return statement stops the function and returns to the main script, it is not required but it makes the functions easier to understand.U can write a function anywhere in the script, but the usual is to put all functions together at the beginning of the script file.</p>
<p><strong><span style="text-decoration:underline;">Returning values back from functions:</span></strong></p>
<p>U can pass value back from a function, using the return statement. it can only return one value. However remember that the return value can be an array; thus it is actually more than one value!</p>
<p>u can also use the return statement in a conditional statement to end the function.</p>
<p>Example:</p>
<p>&lt;?php<br />
function welcome()<br />
{<br />
echo &#8220;Welcome&#8221;;<br />
return;<br />
}<br />
function name()<br />
{<br />
return Noor;<br />
}<br />
?&gt;</p>
<p>&lt;h3&gt; Functions in PHP &lt;/h3&gt;</p>
<p>&lt;?php<br />
$name_variable= name();<br />
welcome();<br />
echo &#8220;  $name_variable&#8221;;<br />
?&gt;<br />
The output:</p>
<h3>Functions in PHP</h3>
<p>Welcome  Noor</p>
<p><strong><span style="text-decoration:underline;">Using variables in functions (another method to return more than 1 value):</span></strong></p>
<p>u can create as many variables as u wish inside the function, these variables r local. which means that they r accessable inside the function, also notice that the function can&#8217;t access any variable inside the function except in the case that this variable is set to be global!</p>
<p>by using global variables inside the function, u can return as many value as u wish <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Example1 ( Local variables ,,, notice how u don&#8217;t get the result u want ):</p>
<p>&lt;?php<br />
$x=3;<br />
$y=2;</p>
<p>function addition()<br />
{<br />
$sum= $x + $y;<br />
}<br />
addition();</p>
<p>echo &#8220;The sum result =&#8221;, $sum;<br />
?&gt;</p>
<p>The output for the first example:</p>
<p>The sum result =</p>
<p>Example2:</p>
<p>&lt;?php<br />
function addition($x1,$y1)<br />
{<br />
global  $sum;<br />
$sum= $x1 + $y1;<br />
return;<br />
}</p>
<p>$x=5;<br />
$y= 2;</p>
<p>addition($x,$y);</p>
<p>echo &#8220;The sum result =&#8221;, $sum;<br />
?&gt;</p>
<p>The output for Example2:</p>
<p>The sum result =7</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/340/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/340/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/340/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=340&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/09/24/creating-reusable-codefunctions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>
	</item>
		<item>
		<title>Repeating actions by using loops</title>
		<link>http://me2learn.wordpress.com/2008/09/20/repeating-actions-by-using-loops/</link>
		<comments>http://me2learn.wordpress.com/2008/09/20/repeating-actions-by-using-loops/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 19:34:58 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[Basic PHP programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[advanced for loop]]></category>
		<category><![CDATA[Avoiding infinite loops]]></category>
		<category><![CDATA[Breaking out of loops:]]></category>
		<category><![CDATA[do while loops]]></category>
		<category><![CDATA[For loop]]></category>
		<category><![CDATA[loops in PHP]]></category>
		<category><![CDATA[while loops]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=334</guid>
		<description><![CDATA[Loops r used frequently in scripts to set up a block of statements that repeated. The loop ca repeated according to:

Specific number of times
until a certain condition is met

there r three types of loops:
1. For loop:
In this type of loops, we set up a counter and repeats a block of statement until the counter reaches [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=334&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Loops r used frequently in scripts to set up a block of statements that repeated. The loop ca repeated according to:</p>
<ul>
<li>Specific number of times</li>
<li>until a certain condition is met</li>
</ul>
<p>there r three types of loops:</p>
<p><strong><span style="text-decoration:underline;">1. For loop:</span></strong></p>
<p>In this type of loops, we set up a counter and repeats a block of statement until the counter reaches a specific number. u set at the beginning a counter value, set the ending value and set how u want the counter to be incremented or decremented.</p>
<p><span style="color:#ff0000;">for (<em>starting_value ; ending condition ; increment</em>)</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><em><span style="color:#ff0000;">block of statement</span></em></p>
<p><span style="color:#ff0000;">}</span></p>
<ul>
<li>starting value: its the statement that sets up a variable to be ur counter and sets its initial value</li>
<li>ending condition: This is the statement that sets ur ending value, as long as the condition is true, the loop will keep executed</li>
<li>increment: The statement that increments ur counter</li>
</ul>
<p>Notice that u can nest as much loops as u wish.</p>
<p>Example:</p>
<p>&lt;?php</p>
<p>for ($i=1; $i&lt;=5; $i++)<br />
{<br />
echo &#8220;This is line number &#8220;,$i,&#8221;&lt;br&gt;&#8221;;<br />
}<br />
?&gt;</p>
<p>The output:</p>
<p>This is line number 1<br />
This is line number 2<br />
This is line number 3<br />
This is line number 4<br />
This is line number 5</p>
<p><strong><span style="text-decoration:underline;">2. advanced for loop:</span></strong></p>
<p><span style="color:#ff0000;">for (<em> beginning statements ; conditional statements ; ending statements </em>)</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><em><span style="color:#ff0000;">block of statement</span></em></p>
<p><span style="color:#ff0000;">}</span></p>
<ul>
<li>beginning statements: they r executed once at the start of the loop, they can be any statements to set up any need values or other statements u want to execute before the loop starts</li>
<li>the conditional statements: they r tested for each iteration of ur loop</li>
<li>the ending statements: they executed once at the end of the loop</li>
</ul>
<p>Each statements section can contain as many statements as u wish, just make sure to separate &#8216;em using commas, and to separate each section using semicolon ; and remember that any section can be empty</p>
<p><strong><span style="text-decoration:underline;">3. while loops:</span></strong></p>
<p>A while loop continue repeating as long as certain conditions r true, first of all u set up a condition, the condition is tested at the top of each loop and it will repeats till the condition is false.</p>
<p><span style="color:#ff0000;">while( <em>condition</em>)</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><em><span style="color:#ff0000;">block of statements</span></em></p>
<p><span style="color:#ff0000;">}</span></p>
<p>Example:</p>
<p>in this example we have a variable called $array and it contain names, we will make a while loop to search for specific name if exist and if so to know how many times it exist.</p>
<p>in this example I used the if statement, if u r confused about it, u can check my previous post:</p>
<p><a title="Using conditional statements" href="../2008/09/20/using-conditional-statements/">Using conditional statements<br />
</a></p>
<p>also I used arrays, if u &#8216;ve any problems with understand it, plz check: <a title="Creating arrays" href="../2008/09/17/creating-arrays-php/">Creating arrays</a></p>
<p>The code for the example:</p>
<p>&lt;?php<br />
$array = array (&#8220;Ali&#8221;,&#8221;Tony&#8221;,&#8221;Moneer&#8221;,&#8221;Sameer&#8221;,&#8221;David&#8221;, &#8220;Sami&#8221;, &#8220;George&#8221;,&#8221;Joe&#8221;,&#8221;Alicia&#8221;,<br />
&#8220;Sarah&#8221;, &#8220;sally&#8221;,&#8221;Moneka&#8221;, &#8220;Richeal&#8221;,&#8221;Phebi&#8221;,&#8221;Razan&#8221;,&#8221;Mellanie&#8221;,&#8221;Noor&#8221;,&#8221;Sabrina&#8221;,&#8221;Ali&#8221;,&#8221;Tony&#8221;,&#8221;Tony&#8221;);</p>
<p>$array_size= sizeof($array);<br />
$counter=0;<br />
$searchvalue=&#8221;Tony&#8221;;<br />
$search_repeated=0;</p>
<p>while ($counter&lt;=$array_size)<br />
{<br />
If ($array[$counter] == $search_value)<br />
{<br />
$search_repeated ++;<br />
}<br />
$counter ++;<br />
}</p>
<p>if ($search_repeated ==0)<br />
{<br />
echo &#8220;The item &#8220;,$search_value, &#8221; was not founded in the array&#8221;;<br />
}<br />
else<br />
{<br />
echo &#8220;The item &#8220;,$search_value, &#8221; was founded &#8220;, $search_repeated , &#8221; in the array&#8221;;<br />
}<br />
?&gt;</p>
<p>The output:</p>
<p>The item Tony was founded 3 in the array</p>
<p><strong><span style="text-decoration:underline;">4. do while loops:</span></strong></p>
<p>They r so similar to the while loops, except that the conditions r tested at the bottom of each loop. Therefor the loop will execute at least once if the conditions r false.</p>
<p><span style="color:#ff0000;">do</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><em><span style="color:#ff0000;">block of statements</span></em></p>
<p><span style="color:#ff0000;">} while (<em>conditions</em>);</span></p>
<p><strong><em><span style="text-decoration:underline;">Note1: Avoiding infinite loops: </span></em></strong></p>
<p>U can reach a point where the loop will never ends, in this case u have a serious problem in ur loop, so make sure of the condition and that ur counter(for loops) is incremented. If u r using PHP for a web page it will stop by itself after 30 seconds (it will timed out).</p>
<p><strong><em><span style="text-decoration:underline;">Note2: Breaking out of loops:</span></em></strong></p>
<p>there r two types to break out of the loop</p>
<ol>
<li>break: breaks completely from the loop and continue to the next statement after the loop</li>
<li>continue: skips to the end of the loop where the condition is tested, id the condition is positive then the scripts continue from the beginning of the loop.</li>
</ol>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/334/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=334&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/09/20/repeating-actions-by-using-loops/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>
	</item>
		<item>
		<title>Using conditional statements</title>
		<link>http://me2learn.wordpress.com/2008/09/20/using-conditional-statements/</link>
		<comments>http://me2learn.wordpress.com/2008/09/20/using-conditional-statements/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 14:30:39 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[Basic PHP programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[conditional statements in PHP]]></category>
		<category><![CDATA[conditions in PHP]]></category>
		<category><![CDATA[if statement in PHP]]></category>
		<category><![CDATA[switch statement in PHP]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=331</guid>
		<description><![CDATA[Conditional statements executes a block of statements only when certain conditions r true.
1. Using If statement:
The general format of and if conditional statement is as follows:
if (condition)
{
block of statements
} 
elseif (condition)
{
block of statements
} 
else
{
block of statements
} 
Explanations:

if: The block of statements executes if the condition is true only and after executing it, the script moves [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=331&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Conditional statements executes a block of statements only when certain conditions r true.</p>
<p><strong><span style="text-decoration:underline;">1. Using If statement:</span></strong></p>
<p>The general format of and if conditional statement is as follows:</p>
<p><span style="color:#ff0000;">if (<em>condition</em>)</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><em><span style="color:#ff0000;">block of statements</span></em></p>
<p><span style="color:#ff0000;">} </span></p>
<p><span style="color:#ff0000;">elseif </span><span style="color:#ff0000;">(<em>condition</em>)</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><span style="color:#ff0000;">block of statements</span></p>
<p><span style="color:#ff0000;">} </span></p>
<p><span style="color:#ff0000;">else</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><em><span style="color:#ff0000;">block of statements</span></em></p>
<p><span style="color:#ff0000;">} </span></p>
<p>Explanations:</p>
<ul>
<li>if: The block of statements executes if the condition is true only and after executing it, the script moves to the next instruction skipping any elseif or else statements (only 1 part will execute). If the condition is false then it will move to line below the curly braes, whatever it&#8217;s elseif or else or another statement.</li>
<li>elseif: This section is optional, u can use more than one elseif, they executes in the same way as the above if</li>
<li>else: This section is also optional, only one else statement is allowed and this part doesn&#8217;t test any condition bcz PHP consider that when the script reach that point then no other statments above was executed and thus the else condition will be true.</li>
</ul>
<p>Example:</p>
<p>we want to print the student grade with a message and with a grade symbol, like the following:</p>
<table border="1">
<tbody>
<tr>
<td>grade range</td>
<td>Message</td>
<td>grade symbol</td>
</tr>
<tr>
<td>99-89</td>
<td>Excellent</td>
<td>A</td>
</tr>
<tr>
<td>90-79</td>
<td>Very good</td>
<td>B</td>
</tr>
<tr>
<td>80-69</td>
<td>Good</td>
<td>C</td>
</tr>
<tr>
<td>70-59</td>
<td>O.K</td>
<td>D</td>
</tr>
<tr>
<td>60-49</td>
<td>Poor</td>
<td>E</td>
</tr>
<tr>
<td>less than 50</td>
<td>Failed!</td>
<td>F</td>
</tr>
</tbody>
</table>
<p>&lt;?php<br />
$grade_check= 75;</p>
<p>if ($grade_check&lt;100 and $grade_check &gt;89)<br />
{<br />
$grade= &#8220;A&#8221;;<br />
$message = &#8220;Excellent&#8221;;<br />
}<br />
elseif ($grade_check &lt;90 and $grade_check &gt; 79)<br />
{<br />
$grade= &#8220;B&#8221;;<br />
$message = &#8220;Very good&#8221;;<br />
}<br />
elseif ($grade_check &lt;80 and $grade_check &gt; 69)<br />
{<br />
$grade= &#8220;C&#8221;;<br />
$message = &#8220;Good&#8221;;<br />
}<br />
elseif ($grade_check &lt;70 and $grade_check &gt;59)<br />
{<br />
$grade= &#8220;D&#8221;;<br />
$message = &#8220;O.K&#8221;;<br />
}<br />
elseif ($grade_check &lt;60 and $grade_check&gt; 49)<br />
{<br />
$grade= &#8220;E&#8221;;<br />
$message = &#8220;Poor&#8221;;<br />
}<br />
else<br />
{<br />
$grade= &#8220;F&#8221;;<br />
$message = &#8220;Failed!&#8221;;</p>
<p>}</p>
<p>echo &#8220;for the student grade = &#8220;, $grade_check, &#8220;&lt;br&gt;&#8221;,$message, &#8220;    ( &#8220;,$grade, &#8221; )&lt;br&gt;&#8221;;<br />
?&gt;</p>
<p>The output for three random grades:</p>
<p>for the student grade = 75<br />
Good	( C )</p>
<p>for the student grade = 64<br />
O.K	( D )</p>
<p>for the student grade = 95<br />
Excellent	( A )</p>
<p><strong><em><span style="text-decoration:underline;">Note1: </span></em></strong>U can test 4 negative if statements that is the block of statements r executed when the condition is false, by adding exclamation point (!) at the beginning of the condition. i.e. if( ! $number &gt;5) then the block of statements will execute only if the $number contains value less than or equal 5.</p>
<p><strong><em><span style="text-decoration:underline;">Note2:</span></em> </strong>U can have nested if statement by adding if statement inside another if, and so on. this is called nesting. but remember that u can&#8217;t reach the inner if , if the outer if isn&#8217;t true &#8230; the block of statements will execute only if all the if&#8217;s r true in the path till reach that block!</p>
<p><strong><span style="text-decoration:underline;">1. Using Switch statement:</span></strong></p>
<p>switch statement is a good option when u &#8216;ve a lot of conditions. The  switch statement tests the value of one variable and then executes the block of variables that matching the value in the variable.</p>
<p><span style="color:#ff0000;">switch (<em>$variable_name</em>)</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><span style="color:#ff0000;">case <em>value</em>:</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><em><span style="color:#ff0000;">Block of statements</span></em></p>
<p><span style="color:#ff0000;">}</span></p>
<p><span style="color:#ff0000;">case <em>value</em>:</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><em><span style="color:#ff0000;">Block of statements</span></em></p>
<p><span style="color:#ff0000;">}</span></p>
<p><span style="color:#ff0000;">.</span></p>
<p><span style="color:#ff0000;">.</span></p>
<p><span style="color:#ff0000;">.</span></p>
<p><span style="color:#ff0000;">default:</span></p>
<p><span style="color:#ff0000;">{</span></p>
<p><em><span style="color:#ff0000;">Block of statements</span></em></p>
<p><span style="color:#ff0000;">}</span></p>
<p><span style="color:#ff0000;">}</span></p>
<ul>
<li>The default section is optional, works like else in the if statements, and it will exucute only it the variable value didn&#8217;t match any case statement, u can place it anywhere but it make more sense to add it at the end of the switch statement.</li>
<li>The break statements r essentials, if u didn&#8217;t write it, if the case if true it will contiue to execute all the cases below it without checking the condition.</li>
</ul>
<p>Example:</p>
<p>the same as the above example but we will write it using switch<br />
&lt;?php<br />
$grade_check_s= 48;<br />
switch ($grade_check_s)<br />
{case ($grade_check_s &lt;100 and $grade_check_s &gt;89):<br />
{<br />
$grade_s= &#8220;A&#8221;;<br />
$message_s = &#8220;Excellent&#8221;;<br />
break;<br />
}<br />
case ($grade_check_s &lt;90 and $grade_check_s &gt;79):<br />
{<br />
$grade_s= &#8220;B&#8221;;<br />
$message_s = &#8220;Very good&#8221;;<br />
break;<br />
}<br />
case ($grade_check_s &lt;80 and $grade_check_s &gt;69):<br />
{<br />
$grade_s= &#8220;C&#8221;;<br />
$message_s = &#8220;Good&#8221;;<br />
break;<br />
}<br />
case ($grade_check_s &lt;70 and $grade_check_s &gt;59):<br />
{<br />
$grade_s= &#8220;D&#8221;;<br />
$message_s = &#8220;O.K&#8221;;<br />
break;<br />
}<br />
case ($grade_check_s &lt;60 and $grade_check_s &gt;49):<br />
{<br />
$grade_s= &#8220;E&#8221;;<br />
$message_s = &#8220;Poor&#8221;;<br />
break;<br />
}</p>
<p>default:<br />
{<br />
$grade_s= &#8220;F&#8221;;<br />
$message_s = &#8220;Failed!&#8221;;</p>
<p>}<br />
}</p>
<p>echo &#8220;for the student grade = &#8220;, $grade_check_s, &#8220;&lt;br&gt;&#8221;,$message_s, &#8220;    ( &#8220;,$grade_s, &#8221; )&lt;br&gt;&#8221;;<br />
?&gt;</p>
<p>The output for three random grades:</p>
<p>for the student grade = 48<br />
Failed!	( F )</p>
<p>for the student grade = 86<br />
Very good	( B )</p>
<p>for the student grade = 77<br />
Good	( C )</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/331/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=331&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/09/20/using-conditional-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>
	</item>
		<item>
		<title>pattern matching with regular expressions</title>
		<link>http://me2learn.wordpress.com/2008/09/19/pattern-matching-with-regular-expressions/</link>
		<comments>http://me2learn.wordpress.com/2008/09/19/pattern-matching-with-regular-expressions/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 14:47:30 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[Basic PHP programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[comparing string to patterns in PHP]]></category>
		<category><![CDATA[Joining multiple comparisons in PHP]]></category>
		<category><![CDATA[special characters for plttern in PHP]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=328</guid>
		<description><![CDATA[Sometimes u need to compare character strings to c whether they fit certain characteristics rather than to check if they match exact values. For this type of comparison, u compare the string to a pattern, they r called regular expressions. One common use of &#8216;em is to check the input from a web page form.
In [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=328&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Sometimes u need to compare character strings to c whether they fit certain characteristics rather than to check if they match exact values. For this type of comparison, u compare the string to a pattern, they r called regular expressions. One common use of &#8216;em is to check the input from a web page form.</p>
<p>In the table below some special characters: (all other characters r literal without any special meaning):</p>
<table border="1">
<tbody>
<tr>
<td>character</td>
<td>Meaning</td>
<td>Example</td>
<td>Matched</td>
<td>Unmatched</td>
</tr>
<tr>
<td>^</td>
<td>Beginning</td>
<td>^n</td>
<td>noor</td>
<td>my name is noor</td>
</tr>
<tr>
<td>$</td>
<td>end of line</td>
<td>n$</td>
<td>lookin$</td>
<td>looking</td>
</tr>
<tr>
<td>.</td>
<td>any single character</td>
<td>&#8230;</td>
<td>ice</td>
<td>A</td>
</tr>
<tr>
<td>?</td>
<td>the preceding character is optional</td>
<td>Noo?r</td>
<td>Nor, Noor</td>
<td>Nour</td>
</tr>
<tr>
<td>()</td>
<td>group literal characters into a string</p>
<p>that must be matched exactly</td>
<td>N(oo)r</td>
<td>Noor</td>
<td>Nour</td>
</tr>
<tr>
<td>[]</td>
<td>enclose a set of optional literal characters</td>
<td>No[ou]r</td>
<td>Noor,Nour</td>
<td>Nor</td>
</tr>
<tr>
<td>[^]</td>
<td>enclose a set of non-matching optional characters</td>
<td>Noo[^v]r</td>
<td>Noor</td>
<td>Noovr</td>
</tr>
<tr>
<td>-</td>
<td>a range of possible</td>
<td>No[n-p]r</td>
<td>Noor, Nonr</td>
<td>Noar</td>
</tr>
<tr>
<td>+</td>
<td>one or more of the preceding character</td>
<td>Noo+r</td>
<td>Noooor,Nooor</td>
<td>Noor</td>
</tr>
<tr>
<td>*</td>
<td>zero or more of the preceding character</td>
<td>Nooo*r</td>
<td>Noor, Nooor</td>
<td>Norr</td>
</tr>
<tr>
<td>{n}</td>
<td>repeat n times</td>
<td>No{2}r</td>
<td>Noor</td>
<td>Nooor</td>
</tr>
<tr>
<td>{n1,n2}</td>
<td>specifies a range of changes</td>
<td>N{1-4}r</td>
<td>Noor</td>
<td>Noooooooooor</td>
</tr>
<tr>
<td>\</td>
<td>The following character is literal (not special character)</td>
<td>N\*r</td>
<td>N*r</td>
<td>Noor</td>
</tr>
<tr>
<td>(||)</td>
<td>a set of alternate string</td>
<td>(Noor || Nour)</td>
<td>Noor, Nour</td>
<td>Sarah</td>
</tr>
</tbody>
</table>
<p><span style="text-decoration:underline;"><strong>comparing string to patterns:</strong></span></p>
<p>u can compare string to patterns using ereg:</p>
<p><span style="color:#ff0000;">ereg (&#8220;<em>pattern</em>&#8220;,<em>value</em>);</span></p>
<p>It will return TRUE or FALSE</p>
<p><strong><span style="text-decoration:underline;">Joining multiple comparisons:</span></strong></p>
<p>U can connect as many conditions as u want in one condition statement, using one of this three words:</p>
<ul>
<li>and: both comparisons r true</li>
<li>or: one of the comparisons is true or both r true</li>
<li>xor: one of the comparisons is true but not both r true</li>
</ul>
<p>The compression using and r tested first, then xor and at the end or r compared. If u want to change the order they r checked, simply use parentheses, its better to use parentheses even if u know the order, bcz unnecessary parentheses can&#8217;t hurt but to have unexpected result can!</p>
<p><span style="text-decoration:underline;"><strong><em>Note:</em></strong></span> In some programming languages like C++ and Jave, u find || and &amp;&amp; for (or and  and in order), they work in PHP as well, they will do the same or and and functionality but || is checked before or , also &amp;&amp; is checked before and!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/328/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=328&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/09/19/pattern-matching-with-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>
	</item>
		<item>
		<title>Changing the order of statement execution</title>
		<link>http://me2learn.wordpress.com/2008/09/19/changing-the-order-of-statement-execution/</link>
		<comments>http://me2learn.wordpress.com/2008/09/19/changing-the-order-of-statement-execution/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 13:57:02 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[Basic PHP programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Changing the order of statement execution in PHP]]></category>
		<category><![CDATA[Checking variable content in PHP]]></category>
		<category><![CDATA[Conditions and conditions operators in PHP]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=325</guid>
		<description><![CDATA[PHP scripts r series of instructions in a file and they r executed one after another from the beginning (top of the file) to the end.
To change the flow of the script u need to add complex statements, PHP provides two types of &#8216;em:

Conditional statements: U set up statements that execute only if a certain [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=325&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>PHP scripts r series of instructions in a file and they r executed one after another from the beginning (top of the file) to the end.</p>
<p>To change the flow of the script u need to add complex statements, PHP provides two types of &#8216;em:</p>
<ul>
<li>Conditional statements: U set up statements that execute only if a certain conditions r met. (If statement and switch statement)</li>
<li>Looping statements: U can execute a statements repeatedly; this is called looping. (for, while and do&#8230; while statements)</li>
</ul>
<p>Both types of complex statements execute a block of statements based on a condition. That is if the condition is true in the &#8220;Conditional statements&#8221; then the statements will execute once but  if the condition is true in the &#8220;Looping statements&#8221; then the statements will execute till the condition become not true.</p>
<p><strong><span style="text-decoration:underline;">Conditions and conditions operators:</span></strong></p>
<p>Conditions r expressions that PHP tests or evaluates to c whether they are TRUE or FALSE, to set up conditions u compare values.</p>
<p>U can use several conditions operators, and they r listed in the table below:</p>
<table border="1">
<tbody>
<tr>
<td>Operator</td>
<td>It&#8217;s use</td>
</tr>
<tr>
<td>==</td>
<td>to compare two values</td>
</tr>
<tr>
<td>===</td>
<td>to compare two values in both values and data type</td>
</tr>
<tr>
<td>&gt;</td>
<td>To compare if the first value(to the left) is larger than the second value (to the right)</td>
</tr>
<tr>
<td>&gt;=</td>
<td>To compare if the first value(to the left) is equal or larger than the second value (to the right)</td>
</tr>
<tr>
<td>&lt;</td>
<td>To compare if the first value(to the left) is less than the second value (to the right)</td>
</tr>
<tr>
<td>&lt;=</td>
<td>To compare if the first value(to the left) is equal or less than the second value (to the right_</td>
</tr>
<tr>
<td>!= or &lt;&gt;</td>
<td>returns true if the two values r not equal</td>
</tr>
<tr>
<td>!==</td>
<td>returns true if the two values r not equal in their value or in their data type</td>
</tr>
</tbody>
</table>
<p><strong><em><span style="text-decoration:underline;">note1:</span></em></strong> U can compare both numbers and strings, strings r compared according to their ASCII value.</p>
<p><strong><em><span style="text-decoration:underline;">note2:</span></em></strong> Pay attention when u want to compare values to use double equal == not single equal, coz the single equal will assign the value and it will always return TRUE. i.e: $a==3; (compression) but $a=3; (a will be equal 3 after executing this statement).</p>
<p><strong><span style="text-decoration:underline;">Checking variable content:</span></strong></p>
<p>there is some special test provided by PHP for variables, such as:</p>
<table border="1">
<tbody>
<tr>
<td>Test</td>
<td>Explanation</td>
<td>variable data type</td>
</tr>
<tr>
<td>isset($variable_name);</td>
<td>TRUE if the variable is set even if nothing is stored in it</td>
<td>variable</td>
</tr>
<tr>
<td>empty($variable_name);</td>
<td>TRUE if:1. variable is not set</p>
<p>2.value =0</p>
<p>3. no character for string values</td>
<td>variable</td>
</tr>
<tr>
<td>is_int($variable_name);</td>
<td>TRUE if the data type for the variable is integer</td>
<td>number</td>
</tr>
<tr>
<td>is_array($variable_name);</td>
<td>TRUE if the variable is array</td>
<td>variable</td>
</tr>
<tr>
<td>is_float($variable_name);</td>
<td>TRUE if the data type for the variable is floating point</td>
<td>number</td>
</tr>
<tr>
<td>is_null($variable_name);</td>
<td>TRUE if the value =0 in the variable</td>
<td>variable</td>
</tr>
<tr>
<td>is_numeric($variable_name);</td>
<td>TRUE if the string inside the variable is numeric string</td>
<td>string</td>
</tr>
<tr>
<td>is_string($variable_name);</td>
<td>TRUE if the variable is string</td>
<td>string</td>
</tr>
</tbody>
</table>
<p>u can also test for the negative for any of the above tests by adding ! before it.</p>
<p>i.e.. if u want the reuslt to be FALSE when the variable is set use !isset($variable_name);</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/325/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/325/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/325/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/325/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/325/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=325&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/09/19/changing-the-order-of-statement-execution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>
	</item>
		<item>
		<title>Multidimensional arrays</title>
		<link>http://me2learn.wordpress.com/2008/09/18/multidimensional-arrays/</link>
		<comments>http://me2learn.wordpress.com/2008/09/18/multidimensional-arrays/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 03:24:11 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[PHP Arrays]]></category>
		<category><![CDATA[Variables and Data]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Arrays in PHP]]></category>
		<category><![CDATA[Creating multidimensional arrays]]></category>
		<category><![CDATA[nested foreach statement]]></category>
		<category><![CDATA[Using multidimensional arrays in statements]]></category>
		<category><![CDATA[viewing multidimensional arrays]]></category>
		<category><![CDATA[Walking through a multidimensional arrays]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=322</guid>
		<description><![CDATA[The main Idea in multidimensional array that u store value with more than 1 key. So it looks like an array of arrays.
If u want to store this table in PHP:



Age/Location
U.K
Jordan
Germany


22
Tony
Noor
Victoria


25
Isabella
Mohammad
Sabrina


27
Linda
Hadeel
Brian



each cell &#8216;ve two keys rather than one, so this will be a 2-D array

Keys : 22 &#38; U.K = Tony
Keys: 22 &#38; Jordan = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=322&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The main Idea in multidimensional array that u store value with more than 1 key. So it looks like an array of arrays.</p>
<p>If u want to store this table in PHP:</p>
<table border="1">
<tbody>
<tr>
<td>Age/Location</td>
<td>U.K</td>
<td>Jordan</td>
<td>Germany</td>
</tr>
<tr>
<td>22</td>
<td>Tony</td>
<td>Noor</td>
<td>Victoria</td>
</tr>
<tr>
<td>25</td>
<td>Isabella</td>
<td>Mohammad</td>
<td>Sabrina</td>
</tr>
<tr>
<td>27</td>
<td>Linda</td>
<td>Hadeel</td>
<td>Brian</td>
</tr>
</tbody>
</table>
<p>each cell &#8216;ve two keys rather than one, so this will be a 2-D array</p>
<ul>
<li>Keys : 22 &amp; U.K = Tony</li>
<li>Keys: 22 &amp; Jordan = Noor</li>
<li>keys : 22 &amp; Germany = Victoria</li>
<li>and so on &#8230;.</li>
</ul>
<p><strong><span style="text-decoration:underline;">Creating multidimensional arrays:</span></strong></p>
<p>u can create multidimensional arrays the same way u create one-multidimensional array!</p>
<ol>
<li>U can create &#8216;em with a series of direct statements  <span style="color:#ff0000;"><em>$array_name</em>[<em>key1</em>][<em>key2]</em>= &#8220;<em>Value</em>&#8220;;</span></li>
<li>U can use shortcut to allow PHP to chose the keys  <span style="color:#ff0000;">$<em>array_name</em>[key1][]= &#8220;<em>value</em>&#8220;;</span></li>
<li>U can use array statement <em> </em><span style="color:#ff0000;"><em>$array_name</em> = array ( &#8220;<em>key1</em>&#8221; =&gt; array (&#8220;<em>key2</em>&#8220;=&gt; &#8220;<em>values</em>&#8220;), &#8220;<em>key1</em>&#8221; =&gt; array (&#8220;<em>key2</em>&#8220;=&gt; &#8220;<em>values</em>&#8220;), &#8230;. );</span></li>
</ol>
<p><strong><span style="text-decoration:underline;">viewing multidimensional arrays:</span></strong></p>
<p>u can view multidimensional arrays in the same way u can view one-dimensional array, using var_dump or print_r statements!</p>
<p><strong><span style="text-decoration:underline;">Using multidimensional arrays in statements:</span></strong></p>
<p>u can follow the same procedure u use with one-dimensional arrays to work with this kind of arrays (using &#8216;em with variables or simply edit &#8216;em) and u can echo &#8216;em &#8230; but u should pay attention if u try to combine the values with double quotes that u need to use curly braces to enclose the variable name.</p>
<p><span style="color:#ff0000;">echo &#8221; <em>words here</em> {$<em>array_name</em>[<em>key1</em>][<em>key2]</em>}  &#8220;;</span></p>
<p><strong><em><span style="text-decoration:underline;">Note: </span></em></strong>statements that convert string to arrays (and vice versa) and convert variable to arrays (and vice versa) and statement for arrays operations MOST of &#8216;em won&#8217;t make sense with multidimensional arrays and won&#8217;t work correctly</p>
<p><strong><span style="text-decoration:underline;"><br />
</span></strong></p>
<p><strong><span style="text-decoration:underline;">Walking through a multidimensional arrays:</span></strong></p>
<p>u can walk through two-dimensional arrays using two foreach statement, one foreach statement inside the other (nesting).</p>
<p>If u want to read more about foreach, check my previous post<a title="walking through an array" href="../2008/09/17/walking-through-an-array/"> walking through an array<br />
</a></p>
<p>Example:</p>
<p>&lt;?php</p>
<p>$age_loc[22][uk]=&#8221;Tony&#8221;;<br />
$age_loc[22][jordan]=&#8221;Noor&#8221;;<br />
$age_loc[22][germany]=&#8221;Victoria&#8221;;</p>
<p>$age_loc[25][uk]=&#8221;Isabella&#8221;;<br />
$age_loc[25][jordan]=&#8221;Mohammad&#8221;;<br />
$age_loc[25][germany]=&#8221;Sabrina&#8221;;</p>
<p>$age_loc[27][uk]=&#8221;Linda&#8221;;<br />
$age_loc[27][jordan]=&#8221;Hadeel&#8221;;<br />
$age_loc[27][germany]=&#8221;Brian&#8221;;</p>
<p>echo &#8220;View \$age_loc array using print_r&lt;br&gt;&lt;pre&gt;&#8221;;<br />
print_r($age_loc);<br />
echo &#8220;&lt;/pre&gt;&lt;br&gt;&#8221;;</p>
<p>echo &#8220;View the value with the keys 27 and germany: {$age_loc[27][germany]}&lt;br&gt;&#8221;;</p>
<p>echo &#8220;&lt;br&gt; Now, lets walk through the array and echo each element&lt;br&gt;&#8221;;</p>
<p>foreach ($age_loc as $age_key =&gt; $age)<br />
{<br />
foreach ($age as $location =&gt; $value)<br />
{<br />
echo &#8220;The person whom his/her age = $age_key &amp; from  $location is $value &lt;br&gt;&#8221;;<br />
}<br />
}</p>
<p>?&gt;</p>
<p>and the output:</p>
<p><span style="font-size:small;">View $age_loc array using print_r<br />
</span></p>
<pre><span style="font-size:small;">Array
(
    [22] =&gt; Array
        (
            [uk] =&gt; Tony
            [jordan] =&gt; Noor
            [germany] =&gt; Victoria
        )

    [25] =&gt; Array
        (
            [uk] =&gt; Isabella
            [jordan] =&gt; Mohammad
            [germany] =&gt; Sabrina
        )

    [27] =&gt; Array
        (
            [uk] =&gt; Linda
            [jordan] =&gt; Hadeel
            [germany] =&gt; Brian
        )

)
</span></pre>
<p><span style="font-size:small;"><br />
View the value with the keys 27 and germany: Brian</p>
<p>Now, lets walk through the array and echo each element<br />
The person whom his/her age = 22 &amp; from  uk is Tony<br />
The person whom his/her age = 22 &amp; from  jordan is Noor<br />
The person whom his/her age = 22 &amp; from  germany is Victoria<br />
The person whom his/her age = 25 &amp; from  uk is Isabella<br />
The person whom his/her age = 25 &amp; from  jordan is Mohammad<br />
The person whom his/her age = 25 &amp; from  germany is Sabrina<br />
The person whom his/her age = 27 &amp; from  uk is Linda<br />
The person whom his/her age = 27 &amp; from  jordan is Hadeel<br />
The person whom his/her age = 27 &amp; from  germany is Brian </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/me2learn.wordpress.com/322/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/me2learn.wordpress.com/322/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/322/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=322&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/09/18/multidimensional-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>
	</item>
		<item>
		<title>Some arrays operations</title>
		<link>http://me2learn.wordpress.com/2008/09/17/some-arrays-operations/</link>
		<comments>http://me2learn.wordpress.com/2008/09/17/some-arrays-operations/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 19:42:18 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[PHP Arrays]]></category>
		<category><![CDATA[Variables and Data]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Arrays in PHP]]></category>
		<category><![CDATA[Exchanging keys and values]]></category>
		<category><![CDATA[Finding array size]]></category>
		<category><![CDATA[Removing duplicate items]]></category>
		<category><![CDATA[Summing arrays]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=319</guid>
		<description><![CDATA[Summing arrays:
To add all the elements in the array, use this statement:
$sum_result= array_sum($array_name);
If u try to add some elements which is not numbers, PHP will autiomatically convert them to number with the zero value!
Example:
&#60;?php
$sum_array= array (1,2,3,4);
$sum_result = array_sum($sum_array);
echo &#8220;The sum of all elements in the \$sum_array = &#8220;,$sum_result;
?&#62;
The output:
The sum of all elements in the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=319&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="text-decoration:underline;"><strong>Summing arrays:</strong></span></p>
<p>To add all the elements in the array, use this statement:</p>
<p><span style="color:#ff0000;"><em>$sum_result</em>= array_sum(<em>$array_name</em>);</span></p>
<p>If u try to add some elements which is not numbers, PHP will autiomatically convert them to number with the zero value!</p>
<p>Example:</p>
<p>&lt;?php<br />
$sum_array= array (1,2,3,4);<br />
$sum_result = array_sum($sum_array);</p>
<p>echo &#8220;The sum of all elements in the \$sum_array = &#8220;,$sum_result;<br />
?&gt;</p>
<p>The output:</p>
<p><span style="font-size:small;">The sum of all elements in the $sum_array = 10 </span></p>
<p><strong><span style="text-decoration:underline;">Removing duplicate items:</span></strong></p>
<p>to remove duplicate items, use the following statement:</p>
<p><span style="color:#ff0000;"><em>$array_without_duplicate_values</em>= array_unique(<em>$array_name)</em>;</span></p>
<p>Example:</p>
<p>&lt;?php</p>
<p>$aaray_with_duplicate= array (&#8220;A1&#8243;,&#8221;B1&#8243;,&#8221;C1&#8243;,&#8221;A1&#8243;);<br />
$aaray_without_duplicate= array_unique($aaray_with_duplicate);</p>
<p>echo &#8220;The array with duplicate elements &lt;br&gt;&lt;pre&gt;&#8221;;<br />
print_r($aaray_with_duplicate);<br />
echo &#8220;&lt;/pre&gt;&#8221;;<br />
echo &#8220;The array without duplicate elements&lt;br&gt;&lt;pre&gt;&#8221;;<br />
print_r($aaray_without_duplicate);<br />
echo &#8220;&lt;/pre&gt;&#8221;;<br />
?&gt;</p>
<p>The output:</p>
<p><span style="font-size:small;">The array with duplicate elements<br />
</span></p>
<pre><span style="font-size:small;">Array
(
    [0] =&gt; A1
    [1] =&gt; B1
    [2] =&gt; C1
    [3] =&gt; A1
)
</span></pre>
<p><span style="font-size:small;">The array without duplicate elements<br />
</span></p>
<pre><span style="font-size:small;">Array
(
    [0] =&gt; A1
    [1] =&gt; B1
    [2] =&gt; C1
)
</span></pre>
<p><strong><span style="text-decoration:underline;">Exchanging keys and values:</span></strong></p>
<p>To exchange values and keys in an arrays:</p>
<p><span style="color:#ff0000;"><em>$array_exchanged</em>= array_flip(<em>$array_name</em>);</span></p>
<p>Example:</p>
<p>&lt;?php<br />
$array_to_flip = array (&#8220;A1&#8243;,&#8221;B1&#8243;,&#8221;C1&#8243;);<br />
$array_exchanged= array_flip($array_to_flip);<br />
echo &#8220;The array before fliping its value with its keys&lt;br&gt;&lt;pre&gt;&#8221;;<br />
print_r($array_to_flip);<br />
echo &#8220;&lt;/pre&gt;&#8221;;<br />
echo &#8220;The array after fliping its value with its keys&lt;br&gt;&lt;pre&gt;&#8221;;<br />
print_r($array_exchanged);<br />
echo &#8220;&lt;/pre&gt;&#8221;;<br />
?&gt;</p>
<p>The output:</p>
<p><span style="font-size:small;">The array before fliping its value with its keys<br />
</span></p>
<pre><span style="font-size:small;">Array
(
    [0] =&gt; A1
    [1] =&gt; B1
    [2] =&gt; C1
)
</span></pre>
<p><span style="font-size:small;">The array after fliping its value with its keys<br />
</span></p>
<pre><span style="font-size:small;">Array
(
    [A1] =&gt; 0
    [B1] =&gt; 1
    [C1] =&gt; 2
)
</span></pre>
<p><strong><span style="text-decoration:underline;">Finding array size:</span></strong></p>
<p>u can use count or sizeof statement to find the size of an array</p>
<p><span style="color:#ff0000;"><em>$size_value</em>= count(<em>$array_name)</em>;</span></p>
<p><span style="color:#ff0000;"><em>$size_value</em>= sizeof(<em>$array_name</em>);</span></p>
<p>the number of elements will be stored in $size_value for each statement!</p>
<p>Example:</p>
<p>&lt;?php</p>
<p>$array_to_find_size= array (&#8220;A1&#8243;,&#8221;B1&#8243;,&#8221;C1&#8243;,&#8221;A2&#8243;,&#8221;B2&#8243;,&#8221;C2&#8243;);<br />
$size_count = count($array_to_find_size);<br />
$size_sizeof= sizeof($array_to_find_size);</p>
<p>echo &#8220;Size of \$ array_to_find_size using count : &#8220;, $size_count,<br />
&#8220;&lt;br&gt;Size of \$ array_to_find_size using sizeof : &#8220;, $size_sizeof;<br />
?&gt;<br />
The output:</p>
<p><span style="font-size:small;"><br />
Size of $ array_to_find_size using count : 6<br />
Size of $ array_to_find_size using sizeof : 6 </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/me2learn.wordpress.com/319/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/me2learn.wordpress.com/319/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/319/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=319&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/09/17/some-arrays-operations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>
	</item>
		<item>
		<title>comparing arrays</title>
		<link>http://me2learn.wordpress.com/2008/09/17/comparing-arrays/</link>
		<comments>http://me2learn.wordpress.com/2008/09/17/comparing-arrays/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 18:50:58 +0000</pubDate>
		<dc:creator>me2blog</dc:creator>
				<category><![CDATA[PHP Arrays]]></category>
		<category><![CDATA[Variables and Data]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Arrays in PHP]]></category>
		<category><![CDATA[array_diff]]></category>
		<category><![CDATA[array_intersect]]></category>
		<category><![CDATA[comparing arrays]]></category>
		<category><![CDATA[find diffrenet elements in an arry]]></category>
		<category><![CDATA[find same elements in an array]]></category>

		<guid isPermaLink="false">http://me2learn.wordpress.com/?p=316</guid>
		<description><![CDATA[can identify the elements that r the same or the elements that r different.
To find different elements:
$difference_array= array_diff($array1, $array2, &#8230;.);
$difference_array contains the elements in array1 and not in array2 or the other arrays.
The order in which u list the arrays make a diffrenence.
To find arrays elements that differ in either value or key, use this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=316&subd=me2learn&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>can identify the elements that r the same or the elements that r different.</p>
<p><span style="text-decoration:underline;"><strong>To find different elements:</strong></span></p>
<p><span style="color:#ff0000;"><em>$difference_array</em>= array_diff(<em>$array1, $array2, &#8230;.</em>);</span></p>
<p>$difference_array contains the elements in array1 and not in array2 or the other arrays.</p>
<p>The order in which u list the arrays make a diffrenence.</p>
<p>To find arrays elements that differ in either value or key, use this statement:</p>
<p><span style="color:#ff0000;"><em>$difference_array</em>= array_diff_assoc(<em>$array1, $array2, &#8230;.</em>);</span></p>
<p><strong><span style="text-decoration:underline;">To find same elements:</span></strong></p>
<p>U can find the same elements in two arrays or more using:</p>
<p><span style="color:#ff0000;"><em>$similar_array</em>= array_intersect(</span><span style="color:#ff0000;"><em>$array1, $array2, &#8230;.</em>);</span></p>
<p>If u want both the value and the key to be the same, use:</p>
<p><span style="color:#ff0000;"><em>$similar_array</em>= array_intersect_assoc(</span><span style="color:#ff0000;"><em>$array1, $array2, &#8230;.</em>);</span></p>
<p>Example:</p>
<p>&lt;?php</p>
<p>$array1_diff= array (&#8220;A1&#8243;,&#8221;B1&#8243;,&#8221;C1&#8243;,&#8221;A2&#8243;,&#8221;B2&#8243;,&#8221;C2&#8243;);<br />
$array2_diff= array (&#8220;A1&#8243;,&#8221;B1&#8243;,&#8221;C1&#8243;);<br />
$array3_diff= array (&#8220;A1&#8243;,&#8221;B1&#8243;,&#8221;C1&#8243;,&#8221;B2&#8243;,&#8221;C2&#8243;);</p>
<p>$diff= array_diff($array1_diff,$array2_diff,$array3_diff);</p>
<p>echo &#8220;The difference: &lt;br&gt; &lt;pre&gt;&#8221;;<br />
print_r($diff);<br />
echo &#8220;&lt;/pre&gt;&#8221;;</p>
<p>$same= array_intersect($array1_diff,$array2_diff,$array3_diff);<br />
echo &#8220;&lt;br &gt;The same elements: &lt;br&gt; &lt;pre&gt;&#8221;;<br />
print_r($same);<br />
echo &#8220;&lt;/pre&gt;&#8221;;</p>
<p>?&gt;</p>
<p>The output:</p>
<p><span style="font-size:small;">The difference:<br />
</span></p>
<pre><span style="font-size:small;">Array
(
    [3] =&gt; A2
)
</span></pre>
<p><span style="font-size:small;"><br />
The same elements:<br />
</span></p>
<pre><span style="font-size:small;">Array
(
    [0] =&gt; A1
    [1] =&gt; B1
    [2] =&gt; C1
)
</span></pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/me2learn.wordpress.com/316/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/me2learn.wordpress.com/316/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/me2learn.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/me2learn.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/me2learn.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/me2learn.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/me2learn.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/me2learn.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/me2learn.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/me2learn.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/me2learn.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/me2learn.wordpress.com/316/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=me2learn.wordpress.com&blog=3908110&post=316&subd=me2learn&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://me2learn.wordpress.com/2008/09/17/comparing-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bf1dba7fbea006741e29d4ae89236122?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">me2blog</media:title>
		</media:content>
	</item>
	</channel>
</rss>