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

<channel>
	<title>NewSourceMedia Blog &#187; PHP</title>
	<atom:link href="http://newsourcemedia.com/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://newsourcemedia.com/blog</link>
	<description>Focused on Interactive Design, Development and Marketing</description>
	<lastBuildDate>Mon, 07 May 2012 01:26:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP how to find Odd and Even numbers</title>
		<link>http://newsourcemedia.com/blog/php-how-to-find-odd-and-even-numbers/</link>
		<comments>http://newsourcemedia.com/blog/php-how-to-find-odd-and-even-numbers/#comments</comments>
		<pubDate>Tue, 30 Nov 1999 06:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Math and Numbers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[compair]]></category>
		<category><![CDATA[digits]]></category>
		<category><![CDATA[even]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[match]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[odd]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/1969/12/31/php-how-to-find-odd-and-even-numbers/</guid>
		<description><![CDATA[Here is how to find odd and even numbers in php. How to find if a number is odd or even? In PHP I learn to use the MOD (%) operator. see below for an example: $i = 10; if &#8230; <a href="http://newsourcemedia.com/blog/php-how-to-find-odd-and-even-numbers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Here is how to find odd and even numbers in php.
<span id="more-173"></span>

How to find if a number is odd or even?
In PHP I learn to use the MOD (%) operator. see below for an example: <code>$i = 10;</code>

<code>if ($i % 2) {
echo "$i is odd";
} else {
echo "$i is even";
}
</code>

You can also use the PHP "&amp;" operator that will give you better   performance
You can use the PHP code like so:

<code>$i = 10;
if ( $i&amp;1 )
{
echo "$i is odd";
}
else
{
echo "$i is even";
}</code>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-how-to-find-odd-and-even-numbers/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>PHP replace only first occurrence of a string match.</title>
		<link>http://newsourcemedia.com/blog/php-replace-only-first-occurrence-of-a-string-match/</link>
		<comments>http://newsourcemedia.com/blog/php-replace-only-first-occurrence-of-a-string-match/#comments</comments>
		<pubDate>Tue, 30 Nov 1999 06:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[String Manipulation]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[match ereg_replace]]></category>
		<category><![CDATA[occurrences]]></category>
		<category><![CDATA[pattern.]]></category>
		<category><![CDATA[preg_replace]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/1969/12/31/php-replace-only-first-occurrence-of-a-string-match/</guid>
		<description><![CDATA[How to replace only the first occurrence of a string in php. Say you wanted to only replace the first occurrence of a string match instead of all occurrences You would use php preg_replace function to do the trick. The &#8230; <a href="http://newsourcemedia.com/blog/php-replace-only-first-occurrence-of-a-string-match/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[How to replace only the first occurrence of a string in php.

<span id="more-172"></span>

Say you wanted to only replace the       first occurrence of a string match instead of all occurrences You would       use php preg_replace function to do the trick.

The code is below:
<code>
&lt;?
$var = 'abcdef abcdef abcdef';
// pattern, replacement, string, limit
echo preg_replace('/abc/', '123', $var, 1); // outputs '123def abcdef abcdef'
?&gt; </code>

Just incase you wanted to still match all occurrences, just use the php       function erag_replace.
The code is below:

<code>
&lt;?
$var = 'abcdef abcdef abcdef';
// pattern, replacement, string
echo ereg_replace('abc', '123', $var); // outputs '123def 123def 123def'
?&gt; </code>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-replace-only-first-occurrence-of-a-string-match/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>PHP Leading Zero for Double Digit Numbers</title>
		<link>http://newsourcemedia.com/blog/php-leading-zero-for-double-digit-numbers/</link>
		<comments>http://newsourcemedia.com/blog/php-leading-zero-for-double-digit-numbers/#comments</comments>
		<pubDate>Tue, 30 Nov 1999 06:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Math and Numbers]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[double digit]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[leading zero]]></category>
		<category><![CDATA[numbers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ten.]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/1969/12/31/php-leading-zero-for-double-digit-numbers/</guid>
		<description><![CDATA[How to output a number with leading zero like dates and time. Question: In php, how do I format my numbers so that all numbers have a double digit. I am displaying the number of days in a month and &#8230; <a href="http://newsourcemedia.com/blog/php-leading-zero-for-double-digit-numbers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[How to output a number with leading zero like dates and time.
<span id="more-171"></span>
Question:
In php, how do I format my numbers so that all numbers have a double digit. I am displaying   the number of days in a month and have to match the date formatted for day.

Answer:
Just check the number value during a loop in php to see if it's less then 10.
Php code is below:
If so then add the leading zero to your string.

<code>&lt;?
for ($num = 1; $num &lt;= 31; $num++) {
if($num&lt;10)
$day = "0$num"; // add the zero
else
$day = "$num"; // don't add the zero
echo "&lt;p&gt;$day&lt;/p&gt;";
?&gt;</code>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-leading-zero-for-double-digit-numbers/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>PHP MySQL Order by Two Columns</title>
		<link>http://newsourcemedia.com/blog/php-mysql-order-by-two-columns/</link>
		<comments>http://newsourcemedia.com/blog/php-mysql-order-by-two-columns/#comments</comments>
		<pubDate>Tue, 30 Nov 1999 06:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL / Database]]></category>
		<category><![CDATA[column]]></category>
		<category><![CDATA[keyword]]></category>
		<category><![CDATA[more]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[order]]></category>
		<category><![CDATA[order by]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[rows]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[two]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/1969/12/31/php-mysql-order-by-two-columns/</guid>
		<description><![CDATA[Here's how to order your data by two or more columns using PHP and MySQL Order by Two Columns Here's how to order by more than one column. When ordering by more than one column, the second column is only &#8230; <a href="http://newsourcemedia.com/blog/php-mysql-order-by-two-columns/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Here's how to order your data by two or more columns using PHP and MySQL<span id="more-166"></span>
<h3>Order by Two Columns</h3>
Here's how to order by more than one column. When ordering by more than   one column, the second column is only used if the values are identical with   the onces in the first column:

<code>SELECT column_name(s)
FROM table_name
ORDER BY column_name1, column_name2</code>
<h3>Sort the display by Ascending or Descending Order</h3>
If you use the ORDER BY keyword, the sort-order of the recordset is ascending   by default (1 before 9 and "a" before "p").

Use the DESC keyword to specify a descending sort-order (9 before 1 and "p" before "a"):

<code>SELECT column_name(s)
FROM table_name
ORDER BY column_name DESC</code>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-mysql-order-by-two-columns/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>PHP Validate Email Address, Phone &amp; URL</title>
		<link>http://newsourcemedia.com/blog/php-validate-email-address-phone-number/</link>
		<comments>http://newsourcemedia.com/blog/php-validate-email-address-phone-number/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 21:09:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[email validater]]></category>
		<category><![CDATA[phone validatoin]]></category>
		<category><![CDATA[php email validation]]></category>
		<category><![CDATA[preg match]]></category>
		<category><![CDATA[validate]]></category>
		<category><![CDATA[validate phon numbers]]></category>

		<guid isPermaLink="false">http://am3media.com/site/?p=155</guid>
		<description><![CDATA[Validate email using PHP grep functions function isValidEmail($email){     return eregi("^+(.+)*@+(.+)*(.{2,3})$", $email); } Validate phone numbers $phone = preg_replace('//', '', $phone); # remove non-numbers // check if > 9 digits if (strlen($phone)>9) { echo 'Valid'; } Validate URL links if(preg_match("/^(http(s?)://&#124;ftp://{1})((w+.){1,})w{2,}$/i", $url)){ &#8230; <a href="http://newsourcemedia.com/blog/php-validate-email-address-phone-number/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Validate email using PHP grep functions
<pre lang="php">function isValidEmail($email){
    return eregi("^+(.+)*@+(.+)*(.{2,3})$", $email);
}</pre>

Validate phone numbers
<pre lang="actionscript">$phone = preg_replace('//', '', $phone); # remove non-numbers
// check if > 9 digits
if (strlen($phone)>9) {
echo 'Valid';
}
</pre>

Validate URL links

<pre lang="php">
if(preg_match("/^(http(s?)://|ftp://{1})((w+.){1,})w{2,}$/i", $url)){
#Is a valid URL
} else {
#Is not a valid URL
}
</pre>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-validate-email-address-phone-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Php Remove Non-Alphanumeric Characters</title>
		<link>http://newsourcemedia.com/blog/php-remove-non-alphanumeric-characters/</link>
		<comments>http://newsourcemedia.com/blog/php-remove-non-alphanumeric-characters/#comments</comments>
		<pubDate>Thu, 28 Dec 2006 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[String Manipulation]]></category>
		<category><![CDATA[characters]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[non-alphanumeric]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[preg match]]></category>
		<category><![CDATA[strip]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2006/12/27/php-remove-non-alphanumeric-characters/</guid>
		<description><![CDATA[How to strip all symbols and numbers from a string of alphanumeric text. This php code will help you delete, remove, strip and erase any non-alphanumeric characters, and then return the data without the unwanted characters. Need help removing un-wanted &#8230; <a href="http://newsourcemedia.com/blog/php-remove-non-alphanumeric-characters/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[How to strip all symbols and numbers from a string  of alphanumeric text. This php code will help you delete, remove, strip and erase any non-alphanumeric characters, and then return the data without the unwanted characters.<span id="more-178"></span>

Need help removing un-wanted characters from your php text form strings. Here's how to  strip a string of all symbols and characters other than alphanumeric letters and numbers from your file or database. This code will delete any non-alphanumeric characters specified between the brackets, and then output/return the clean version.
<h2>The code</h2>
<code><span style="color: #000000;">
<span style="color: #0000bb;">&lt;?php</span></span></code>

$string <span style="color: #007700;">= </span><span style="color: #dd0000;">"Here! is some text, and numbers 12345, and symbols !£$%^&amp;"</span><span style="color: #007700;">;</span>

<span style="color: #0000bb;">$new_string </span><span style="color: #007700;">= </span><span style="color: #0000bb;">preg_replace</span><span style="color: #007700;">(</span><span style="color: #dd0000;">"//"</span><span style="color: #007700;">, </span><span style="color: #dd0000;">""</span><span style="color: #007700;">, </span><span style="color: #0000bb;">$string</span><span style="color: #007700;">);</span>

echo <span style="color: #0000bb;">$new_string</span>

?&gt;

The code should return this:

<code><span style="color: #000000;"><span style="color: #969696;">Here is some text and numbers 12345 and symbols</span></span></code>

One more thing. If you don't like to keep the blank white space in your text just reformat the preg_replace by removing the "\s" whitespace character types. This is good for use with user names and passwords. The code would now look something like this:

<code> <span style="color: #000000;"><span style="color: #969696;">Hereissometextandnumbers12345andsymbols</span></span></code>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-remove-non-alphanumeric-characters/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Create MySQL Database With PHP</title>
		<link>http://newsourcemedia.com/blog/create-mysql-database-with-php/</link>
		<comments>http://newsourcemedia.com/blog/create-mysql-database-with-php/#comments</comments>
		<pubDate>Tue, 26 Dec 2006 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL / Database]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[base]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[information]]></category>
		<category><![CDATA[myslq]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[store]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2006/12/25/create-mysql-database-with-php/</guid>
		<description><![CDATA[Create a dynamic web site by using MySQL Database and PHP. It is easy and I provided the code to cut and paste. Now let get started with PHP and MySQL code for building a Dynamic Web Site: PHP &#38; &#8230; <a href="http://newsourcemedia.com/blog/create-mysql-database-with-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Create a dynamic web site by using MySQL Database and PHP. It is easy and I provided the code to cut and paste.<span id="more-179"></span>

Now let get started with PHP and MySQL code for building a Dynamic Web Site:
<h3>PHP &amp; database connection code in a lib file for inclusion</h3>
1) First we make a php file called "lib.php"
2) Then we add the following php code to the lib.php file for making a connection to the database. Be sure to change the names to match your host name, user name, password and database name :

<span class="code">&lt;?
$dbhost = 'localhost';
$dbuser = 'myusername'; // you must set user name!
$dbpass = 'mypassword'; // you must set pass word!
$dbname = 'car_database'; // you must set database or fill-in database name in the form!</span>
<p class="code">function dbconnect()
{
global $dbhost, $dbuser, $dbpass, $dbname;
mysql_pconnect($dbhost, $dbuser, $dbpass);
@mysql_select_db($dbname) or die ("Unable to select database");
}

<p class="code">function query_db($query)
{
dbconnect();
return @mysql_query($query);
}
?&gt;
<h3>Database Manager (PhpMyAdmin) to create a new table</h3>
3) Open up your database manager (PhpMyAdmin) and select your database, then click the SQL tab or icon for running a SQL query and copy and paste the following code in the text field then click the "Go" or "Submit" button to create the <em>car_table</em> database.
<p class="code">CREATE TABLE car_table (</p>

<p class="code">car_make varchar(250) default NULL,
car_model varchar(250) default NULL,
car_year varchar(250) default NULL,
id_field int(11) NOT NULL auto_increment,
PRIMARY KEY (id_field)
) TYPE=MyISAM;
<h3>PHP code for managing your table fields</h3>
4) <span class="code">Download Code file "cars.txt" here: <a href="../../New%20Tutorials/cars.txt" target="_blank">http://newsourcemedia.com/New Tutorials/cars.txt</a></span>

5)  Rename that file to "cars.php". Notice that the first line of code is there to imports your first file "lib.php". Why? Because for every php file that query's the database will need to make a database connection. So why not use one file to make that connection for all php files.

6) Uploads both the "lib.php" and the "cars.php" to your web server. Make sure both files are in side of the same directory.
<h3>Third PHP file for visitors without the edit or delete functions.</h3>
7) After adding content to your database, you may want to make a third file called "viewcars.php" for the users to view the database list of cars. Do this by duplicating the "cars.php" file. But be sure to <strong>delete </strong>all of the links labeled "delete", "edit" and "add" and remove all php blocks of code that start with "<span class="code">$query=INSERT INTO...</span>, <span class="code">$query=UPDATE...</span>, and <span class="code">$query=DELETE FROM...</span>" to provent visitors from editing your database content.]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/create-mysql-database-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Lesson 3 &#8211; Creating Functions</title>
		<link>http://newsourcemedia.com/blog/php-lesson-3-creating-functions/</link>
		<comments>http://newsourcemedia.com/blog/php-lesson-3-creating-functions/#comments</comments>
		<pubDate>Mon, 02 May 2005 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Beginner]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[create]]></category>
		<category><![CDATA[creating functions.]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[lesson]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2005/05/01/php-lesson-3-creating-functions/</guid>
		<description><![CDATA[How to create Functions in PHP and also how to Pass Variables to Functions. Introduction: You will need to have a PHP web server for this tutorial. We recommend SimpleHost.com for only $7.50 with Unlimited Disk Space, Subdomains, and Emails &#8230; <a href="http://newsourcemedia.com/blog/php-lesson-3-creating-functions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[How to create Functions in PHP and also how to Pass Variables to Functions.
<span id="more-201"></span>
<span class="contitle">Introduction:</span>

You will need to have a PHP web server for this tutorial. We recommend <a href="http://www.simplehost.com/cgi/clickthru.cgi?id=alexmcleaniii">SimpleHost.com</a> for only $7.50 with Unlimited Disk Space, Subdomains, and Emails Accounts.

PHP has hundreds of predefined  functions (maybe thousands). This tutorial gives examples  on how to create your own php functions. There are two rules  I would like to share with you before we start.

<span class="contitle">Rule 1: </span>
Make sure your new function name does not exhist. You can  check PHP.net for a complete list of PHP predefined functions.

<span class="contitle">Rule 2: </span>
Do not declare/define the same function more than once inside the same file. You will get an error.

OK, let's create our first function. This function will display  a text advertisement. We will call this function ads().
<p class="contitle">Source Code</p>

<p class="sourceCODE">&lt;?php
// first define the function
function ads()
{
echo "Visit NewSourceMedia.com for free tutorials";
}
// now call the function ads() like so
ads();
?&gt;

Now you can display the same ad however many times you  want just by calling the function ads().
<p class="contitle">Passing Values to Functions:</p>

Let's say we want to randomly display three ads. We  could do this by placing three text ads inside our ads()  function and then passing a random value to it, to indicate  which ad to display. We can do this by using a parameter  variable inside the function. For example $n will be the  variable and this is how it is placed inside our ads function  like so "ads($n)". This variable holds a copy  of the value passed to it.

Now we need to set $n to a random number between 1 and  3. We can do this by using one of PHP pre-defined functions  called rand(). If you want a random number between 1 and  3 (inclusive), for example, use "rand (1, 3)".  To make this a little more clear, view the code below:
<p class="contitle">Source Code</p>
<p class="sourceCODE">&lt;?php</p>

// first define the function

function ads($n)
{

$a = "http://newsourcemedia.com";

if($n == 1)
echo "&lt;a href='$a'&gt;Visit NewSourceMedia.com for  free tutorials&lt;/a&gt;";

if($n == 2)
echo "&lt;a href='$a'&gt;NewSourceMedia.com for PHP  and much more!&lt;/a&gt;";

if($n == 3)
echo "&lt;a href='$a'&gt;PHP is Number One!&lt;/a&gt;"

} // end of function
<p class="sourceCODE">// define the random value for $n
$n = rand (1, 3);

// now call the function ads() with the value $n
ads($n);

?&gt;]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-lesson-3-creating-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Portion() function for trimming text</title>
		<link>http://newsourcemedia.com/blog/portion-function-for-trimming-text/</link>
		<comments>http://newsourcemedia.com/blog/portion-function-for-trimming-text/#comments</comments>
		<pubDate>Wed, 23 Feb 2005 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[String Manipulation]]></category>
		<category><![CDATA[length]]></category>
		<category><![CDATA[lenth.]]></category>
		<category><![CDATA[short]]></category>
		<category><![CDATA[shorten]]></category>
		<category><![CDATA[shorter]]></category>
		<category><![CDATA[start]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[trim]]></category>
		<category><![CDATA[values]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2005/02/22/portion-function-for-trimming-text/</guid>
		<description><![CDATA[Returns the portion of text specified by the start and length parameters. This help to trim text down for display in a small area or to give a sample of a larger body of text. I created this function to &#8230; <a href="http://newsourcemedia.com/blog/portion-function-for-trimming-text/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Returns the portion of text specified by the start and length parameters. This help to trim text down for display in a small area or to give a sample of a larger body of text.
<span id="more-184"></span>

I created this function to display a portion of listings on my home page under their related links to the full body of content.

This can helps your visitor to find the content faster as well as helps search engine better index your web site.

Portion() Code:
<pre lang="php"> <?
// function starts here
function portion($max_len,$str){
if(!$max_len)
$max_len = 12; // default max length of characters including blank spaces
if (strlen($str) > $max_len){
echo substr("$str", 0, $max_len)."..."; // your portion of text with trailing dots "..."
}
else
echo $str;
}
// function code end here

$str = "Hello World"; // edit or delete this line for your use
portion(7,"$str"); // call the function ( this will return "Hello W..." )

?></pre>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/portion-function-for-trimming-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Order By Multiple Fields in MySQL</title>
		<link>http://newsourcemedia.com/blog/php-order-by-multiple-fields-in-mysql/</link>
		<comments>http://newsourcemedia.com/blog/php-order-by-multiple-fields-in-mysql/#comments</comments>
		<pubDate>Sat, 17 Jul 2004 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ascent]]></category>
		<category><![CDATA[descent]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[order]]></category>
		<category><![CDATA[reorder]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2004/07/16/php-order-by-multiple-fields-in-mysql/</guid>
		<description><![CDATA[Want to be able to order by two or more database fields / columns using the ASC and DESC order clause You can sort query results in ascending or descending order on one or more of the columns in the &#8230; <a href="http://newsourcemedia.com/blog/php-order-by-multiple-fields-in-mysql/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Want to be able to order by two or more database fields / columns using the ASC and DESC order clause
<span id="more-192"></span>

You can sort query results in ascending or descending order on one or more of the columns in the result set by using the ASC or DESC keywords with the ORDER BY clause.

<strong>Ordering By Two Fields</strong>
<p class="sourceCODE">SELECT * FROM table ORDER BY (field1 / field2) DESC</p>

<strong>Ordering By Three Fields</strong>

If both field1 and field2 match in more then one row, then use a third to order them by:
<p class="sourceCODE">SELECT * FROM table ORDER BY (field1 / field2) DESC, field3 DESC</p>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-order-by-multiple-fields-in-mysql/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
