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

<channel>
	<title>Web Design company - Goweb99 blog &#187; PHP Tutorial</title>
	<atom:link href="http://www.goweb99.com/blog/category/php-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.goweb99.com/blog</link>
	<description>Get your website designed for as low as $99.</description>
	<lastBuildDate>Fri, 30 Jul 2010 20:27:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP MySQL Delete</title>
		<link>http://www.goweb99.com/blog/about-websites/php-mysql-delete/</link>
		<comments>http://www.goweb99.com/blog/about-websites/php-mysql-delete/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 11:59:58 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[About Websites]]></category>
		<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[delete statement]]></category>
		<category><![CDATA[MySQL delete]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=710</guid>
		<description><![CDATA[You can delete records by using the DELETE statement.
Syntax
 DELETE FROM table_name
WHERE some_column = some_value
Again we used WHERE clause here in the DELETE syntax. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted.

For eg:
Country Capital
Zimbabwe	Harare
Poland	Warsaw


&#60;?php
$conn = mysql_connect(&#8221;localhost&#8221;,&#8221;tutor&#8221;,&#8221;tutor123&#8243;);
if (!$conn)
{
die(&#8217;Could not connect: &#8216; [...]]]></description>
			<content:encoded><![CDATA[<p>You can delete records by using the DELETE statement.</p>
<p><strong>Syntax</strong></p>
<ul> DELETE FROM table_name<br />
WHERE some_column = some_value</ul>
<p>Again we used WHERE clause here in the DELETE syntax. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted.</p>
<ul>
<div class="example">For eg:</p>
<p><strong>Country Capital</strong><br />
Zimbabwe	Harare<br />
Poland	Warsaw</div>
</ul>
<ul>
<div class="example">&lt;?php<br />
$conn = mysql_connect(&#8221;localhost&#8221;,&#8221;tutor&#8221;,&#8221;tutor123&#8243;);<br />
if (!$conn)<br />
{<br />
die(&#8217;Could not connect: &#8216; . mysql_error());<br />
}<br />
mysql_select_db(&#8221;my_db&#8221;, $conn);<br />
mysql_query(&#8221;DELETE FROM Country WHERE Capital=&#8217;Warsaw&#8217;&#8221;);<br />
mysql_close($conn);<br />
?&gt;</div>
</ul>
<p>After the deletion, the table will look like this:</p>
<ul>
<table border="0" cellpadding="5">
<tbody>
<tr>
<td><strong>Country</strong></td>
<td><strong>Capital</strong></td>
</tr>
<tr>
<td>Zimbabwe</td>
<td>Harare</td>
</tr>
</tbody>
</table>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/about-websites/php-mysql-delete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP MySQL Update</title>
		<link>http://www.goweb99.com/blog/about-websites/php-mysql-update/</link>
		<comments>http://www.goweb99.com/blog/about-websites/php-mysql-update/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 11:44:25 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[About Websites]]></category>
		<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[PHP MySQL Update]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=705</guid>
		<description><![CDATA[The UPDATE statement is used to update existing records of a table in a database.
Syntax

UPDATE table_name
SET column1=value, column2=value2,&#8230;
WHERE some_column=some_value
WHERE clause is included in the update statement to conditionally update the records. It specifies which record or records should be updated. If there is no WHERE clause, all records will be updated.


For eg:
Zimbabwe	Harare
Poland	Warsaw


The following example updates [...]]]></description>
			<content:encoded><![CDATA[<p>The UPDATE statement is used to update existing records of a table in a database.</p>
<p><strong>Syntax</strong></p>
<ul>
UPDATE table_name<br />
SET column1=value, column2=value2,&#8230;<br />
WHERE some_column=some_value</ul>
<p>WHERE clause is included in the update statement to conditionally update the records. It specifies which record or records should be updated. If there is no WHERE clause, all records will be updated.</p>
<ul>
<div class="example">
For eg:</p>
<p>Zimbabwe	Harare<br />
Poland	Warsaw
</p></div>
</ul>
<p>The following example updates some data in the &#8220;Country&#8221; table:</p>
<ul>
<div class="example">
&lt;?php<br />
$con = mysql_connect(&#8221;localhost&#8221;,&#8221;tutor&#8221;,&#8221;tutor123&#8243;);<br />
if (!$conn)<br />
{<br />
die(&#8217;Could not connect: &#8216; . mysql_error());<br />
}<br />
mysql_select_db(&#8221;my_db&#8221;, $con);<br />
mysql_query(&#8221;UPDATE Country SET Capital = &#8216;Poland&#8217;<br />
WHERE FirstName = &#8216;Poland&#8217;&#8221;);<br />
mysql_close($conn);<br />
?&gt;</div>
</ul>
<p>After the update, the &#8220;Country&#8221; table will look like this:</p>
<ul>
<table cellpadding="5">
<tr>
<td><strong>Country</strong></td>
<td><strong>Capital</strong></td>
</tr>
<tr>
<td>Zimbabwe</td>
<td>Harare</td>
</tr>
<tr>
<td>Poland</td>
<td>Poland</td>
</tr>
</table>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/about-websites/php-mysql-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An XML File</title>
		<link>http://www.goweb99.com/blog/php-tutorial/an-xml-file/</link>
		<comments>http://www.goweb99.com/blog/php-tutorial/an-xml-file/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 12:17:20 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[php and xml]]></category>
		<category><![CDATA[xml file]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=740</guid>
		<description><![CDATA[An XML file looks like this:


&#60;?xml version=&#8221;1.0&#8243; encoding=&#8221;ISO-8859-1&#8243;?&#62;
&#60;message&#62;
&#60;sentto&#62;Tutor&#60;/sentto&#62;
&#60;sentby&#62;Goweb99&#60;/sentby&#62;
&#60;subject&#62;Tutorial&#60;/subject&#62;
&#60;content&#62;This is a good tutorial!&#60;/content&#62;
&#60;/message&#62;

Initializing the XML Parser
We need to first initialize the XML parser in PHP, then define some handlers for different XML events, and then parse the XML file.


For eg:
&#60;?php
//Initialize the XML parser
$parser=xml_parser_create();
//Function to use at the start of an element
function start($parser,$element_name,$element_attrs)
{
switch($element_name)
{
case &#8220;MESSAGE&#8221;:
echo &#8220;&#8230;&#8230;&#8230;&#8230;Message&#8230;&#8230;&#8230;&#8230;.&#60;br /&#62;&#8221;;
break;
case &#8220;SENTTO&#8221;:
echo [...]]]></description>
			<content:encoded><![CDATA[<p>An XML file looks like this:</p>
<ul>
<div class="example">
&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;ISO-8859-1&#8243;?&gt;<br />
&lt;message&gt;<br />
&lt;sentto&gt;Tutor&lt;/sentto&gt;<br />
&lt;sentby&gt;Goweb99&lt;/sentby&gt;<br />
&lt;subject&gt;Tutorial&lt;/subject&gt;<br />
&lt;content&gt;This is a good tutorial!&lt;/content&gt;<br />
&lt;/message&gt;</div>
</ul>
<p><strong>Initializing the XML Parser</strong></p>
<p>We need to first initialize the XML parser in PHP, then define some handlers for different XML events, and then parse the XML file.</p>
<ul>
<div class="example">
For eg:</p>
<p>&lt;?php<br />
//Initialize the XML parser<br />
$parser=xml_parser_create();<br />
//Function to use at the start of an element<br />
function start($parser,$element_name,$element_attrs)<br />
{<br />
switch($element_name)<br />
{<br />
case &#8220;MESSAGE&#8221;:<br />
echo &#8220;&#8230;&#8230;&#8230;&#8230;Message&#8230;&#8230;&#8230;&#8230;.&lt;br /&gt;&#8221;;<br />
break;<br />
case &#8220;SENTTO&#8221;:<br />
echo &#8220;Meant for: &#8220;;<br />
break;<br />
case &#8220;SENTBY&#8221;:<br />
echo &#8220;Msg From: &#8220;;</p>
<p>break;<br />
case &#8220;SUBJECT&#8221;:<br />
echo &#8220;Subject: &#8220;;<br />
break;<br />
case &#8220;CONTENT&#8221;:<br />
echo &#8220;Message: &#8220;;<br />
}<br />
}<br />
//Function to use at the end of an element<br />
function stop($parser,$element_name)<br />
{<br />
echo &#8220;&lt;br /&gt;&#8221;;<br />
}<br />
//Function to use when finding character data<br />
function char($parser,$data)<br />
{<br />
echo $data;<br />
}<br />
//Specify element handler<br />
xml_set_element_handler($parser,&#8221;start&#8221;,&#8221;stop&#8221;);<br />
//Specify data handler<br />
xml_set_character_data_handler($parser,&#8221;char&#8221;);<br />
//Open XML file<br />
$fp=fopen(&#8221;sample.xml&#8221;,&#8221;r&#8221;);<br />
//Read data<br />
while ($data=fread($filePointer,4096))<br />
{<br />
xml_parse($parser,$data,feof($filePointer)) or<br />
die (sprintf(&#8221;XML Error: %s at line %d&#8221;,<br />
xml_error_string(xml_get_error_code($parser)),<br />
xml_get_current_line_number($parser)));<br />
}<br />
//Free the XML parser<br />
xml_parser_free($parser);<br />
?&gt;
</p></div>
</ul>
<ul>
<div class="example">
Output:</p>
<p>&#8211;Message&#8211;<br />
Meant for:Tutor<br />
Msg From:Goweb99<br />
Subject: Tutorial<br />
Message: This is a good tutorial!
</p></div>
</ul>
<p>The above example works as:</p>
<ul>
<li>Initialize the XML parser with the xml_parser_create() function</li>
<li>Create functions to use with the different event handlers</li>
<li>Add the xml_set_element_handler() function to specify which function will be executed when the parser encounters the opening and closing tags</li>
<li>Add the xml_set_character_data_handler() function to specify which function will execute when the parser encounters character data</li>
<li>Parse the file &#8220;test.xml&#8221; with the xml_parse() function</li>
<li>In case of an error, add  xml_error_string() function to convert an XML error to a textual description</li>
<li>Call the xml_parser_free() function to release the memory allocated with the xml_parser_create() function</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/php-tutorial/an-xml-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML &amp; EXPAT</title>
		<link>http://www.goweb99.com/blog/about-websites/xml-expat/</link>
		<comments>http://www.goweb99.com/blog/about-websites/xml-expat/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 06:14:27 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[About Websites]]></category>
		<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[expat]]></category>
		<category><![CDATA[expat parser]]></category>
		<category><![CDATA[types of parser]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xml parser]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=734</guid>
		<description><![CDATA[XML
XML is used to describe data. It focuses on what the data is. An XML file describes the structure of the data.
In XML, no tags are predefined. You must define your own tags.
PHP can process XML files with the help of built-in XML Expat Parser.
Expat
To do the manipulation with a file we need to understand [...]]]></description>
			<content:encoded><![CDATA[<p><strong>XML</strong></p>
<p>XML is used to describe data. It focuses on what the data is. An XML file describes the structure of the data.</p>
<p>In XML, no tags are predefined. You must define your own tags.</p>
<p>PHP can process XML files with the help of built-in XML Expat Parser.</p>
<p><strong>Expat</strong></p>
<p>To do the manipulation with a file we need to understand it, this is the work of a parser. Similarly to create, read, update and do other manipulations an XML document, you will need an XML parser.</p>
<p>There are two basic types of XML parsers:</p>
<ul>
<li>Tree-based parser: This parser transforms an XML document into a tree structure. It analyzes the whole document, and provides access to the tree elements. e.g. the Document Object Model (DOM)</li>
<li>Event-based parser: Views an XML document as a series of events. When a specific event occurs, it calls a function to handle it. For e.g. the Expat XML parser</li>
</ul>
<p>Event-based parsers focus on the content of the XML documents, not their structure. Because of this, event-based parsers can access data faster than tree-based parsers.</p>
<ul>
<div class="example">
For eg:</p>
<p>&lt;sent&gt;Data&lt;/sent&gt;</p></div>
</ul>
<p>An event-based parser reports the XML above as a series of three events:</p>
<ul>
<li>Start element: sent</li>
<li>Start CDATA section, value: Data</li>
<li>Close element: from</li>
</ul>
<p>The XML example above contains well-formed XML. However, the example is not valid XML, because there is no Document Type Definition (DTD) associated with it.</p>
<p>However, this makes no difference when using the Expat parser. Expat is a non-validating parser, and ignores any DTDs.</p>
<p>As an event-based, non-validating XML parser, Expat is fast and small, and a perfect match for PHP web applications.</p>
<p><strong>Note: </strong>XML documents must be well-formed or Expat will generate an error.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/about-websites/xml-expat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Database ODBC</title>
		<link>http://www.goweb99.com/blog/about-websites/php-database-odbc/</link>
		<comments>http://www.goweb99.com/blog/about-websites/php-database-odbc/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 12:18:04 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[About Websites]]></category>
		<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[database odbc]]></category>
		<category><![CDATA[odbc]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=716</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/about-websites/php-database-odbc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP MySQL Order By</title>
		<link>http://www.goweb99.com/blog/php-tutorial/php-mysql-order-by/</link>
		<comments>http://www.goweb99.com/blog/php-tutorial/php-mysql-order-by/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 10:31:58 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[order by]]></category>
		<category><![CDATA[php order by]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=701</guid>
		<description><![CDATA[The ORDER BY is a keyword which is used to arrange or sort the data in a recordset.
If  you will not specify in which order to arrange the result, ORDER BY will arrange them in ascending order by default.
If you want to sort the records in a descending order, you can use the DESC keyword.
Syntax

SELECT column_name(s)
FROM [...]]]></description>
			<content:encoded><![CDATA[<p>The ORDER BY is a keyword which is used to arrange or sort the data in a recordset.</p>
<p>If  you will not specify in which order to arrange the result, ORDER BY will arrange them in ascending order by default.</p>
<p>If you want to sort the records in a descending order, you can use the DESC keyword.</p>
<p><strong>Syntax</strong></p>
<ul>
SELECT column_name(s)<br />
FROM table_name<br />
ORDER BY column_name(s) ASC|DESC
</ul>
<ul>
<div class="example">
For eg:</p>
<p>&lt;?php<br />
$conn = mysql_connect(&#8221;localhost&#8221;,&#8221;tutor&#8221;,&#8221;tutor123&#8243;);<br />
if (!$conn)<br />
{<br />
die(&#8217;Could not connect: &#8216; . mysql_error());<br />
}<br />
mysql_select_db(&#8221;my_db&#8221;, $conn);<br />
$result = mysql_query(&#8221;SELECT * FROM Country ORDER BY Country&#8221;);<br />
while($row = mysql_fetch_array($result))<br />
{<br />
echo $row['Country'];<br />
echo &#8221; &#8221; . $row['Capital'];<br />
echo &#8220;&lt;br /&gt;&#8221;;<br />
}<br />
mysql_close($conn);<br />
?&gt;</p></div>
</ul>
<ul>
<div class="example">
Output:</p>
<p>Poland Warsaw<br />
Zimbabwe Harare</p></div>
</ul>
<p><strong>Order by Two Columns</strong></p>
<p>It is also possible to order by more than one column. When ordering by more than one column, the second column is only used if the values in the first column are same:</p>
<ul>
SELECT column_name(s)<br />
FROM table_name<br />
ORDER BY column1, column2</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/php-tutorial/php-mysql-order-by/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP MySQL The Where Clause</title>
		<link>http://www.goweb99.com/blog/php-tutorial/php-mysql-the-where-clause/</link>
		<comments>http://www.goweb99.com/blog/php-tutorial/php-mysql-the-where-clause/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 10:14:53 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[where clause]]></category>
		<category><![CDATA[where clause in mysql]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=699</guid>
		<description><![CDATA[WHERE clause is used to filter records, on the basis of some conditions.
Syntax

SELECT column_name(s)
FROM table_name
WHERE column_name operator value
The following example selects all rows from the &#8220;Country&#8221; table where Country=&#8217;Poland&#8217;.


For eg:
&#60;?php
$conn = mysql_connect(&#8221;localhost&#8221;,&#8221;tutor&#8221;,&#8221;tutor123&#8243;);
if (!$conn)
{
die(&#8217;Could not connect: &#8216; . mysql_error());
}
mysql_select_db(&#8221;my_db&#8221;, $conn);
$result = mysql_query(&#8221;SELECT * FROM Country
WHERE Country=&#8217;Poland&#8217;&#8221;);
while($row = mysql_fetch_array($result))
{
echo $row['Country'] . &#8221; &#8221; . $row['Capital'];
echo &#8220;&#60;br /&#62;&#8221;;
}
?&#62;



Output:
Poland [...]]]></description>
			<content:encoded><![CDATA[<p>WHERE clause is used to filter records, on the basis of some conditions.</p>
<p><strong>Syntax</strong></p>
<ul>
SELECT column_name(s)<br />
FROM table_name<br />
WHERE column_name operator value</ul>
<p>The following example selects all rows from the &#8220;Country&#8221; table where Country=&#8217;Poland&#8217;.</p>
<ul>
<div class="example">
For eg:</p>
<p>&lt;?php<br />
$conn = mysql_connect(&#8221;localhost&#8221;,&#8221;tutor&#8221;,&#8221;tutor123&#8243;);<br />
if (!$conn)<br />
{<br />
die(&#8217;Could not connect: &#8216; . mysql_error());<br />
}<br />
mysql_select_db(&#8221;my_db&#8221;, $conn);<br />
$result = mysql_query(&#8221;SELECT * FROM Country<br />
WHERE Country=&#8217;Poland&#8217;&#8221;);<br />
while($row = mysql_fetch_array($result))<br />
{<br />
echo $row['Country'] . &#8221; &#8221; . $row['Capital'];<br />
echo &#8220;&lt;br /&gt;&#8221;;<br />
}<br />
?&gt;</p></div>
</ul>
<ul>
<div class="example">
Output:</p>
<p>Poland Warsaw</p></div>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/php-tutorial/php-mysql-the-where-clause/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP MySQL Select</title>
		<link>http://www.goweb99.com/blog/php-tutorial/php-mysql-select/</link>
		<comments>http://www.goweb99.com/blog/php-tutorial/php-mysql-select/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 10:06:39 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[displaying select result in a table]]></category>
		<category><![CDATA[mySQL select]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=697</guid>
		<description><![CDATA[The SELECT statement is used to select data from a database, based on some conditions or all of the data.
Syntax
 SELECT column_name(s)
FROM table_name
The following example selects all the data stored in the &#8220;Country&#8221; table.A * character selects all the data in the table.

For eg:
&#60;?php
$conn = mysql_connect(&#8221;localhost&#8221;,&#8221;tutor&#8221;,&#8221;tutor123&#8243;);
if (!$conn)
{
die(&#8217;Could not connect: &#8216; . mysql_error());
}
mysql_select_db(&#8221;my_db&#8221;, $conn);
$result = mysql_query(&#8221;SELECT [...]]]></description>
			<content:encoded><![CDATA[<p>The SELECT statement is used to select data from a database, based on some conditions or all of the data.</p>
<p><strong>Syntax</strong></p>
<ul> SELECT column_name(s)<br />
FROM table_name</ul>
<p>The following example selects all the data stored in the &#8220;Country&#8221; table.A * character selects all the data in the table.</p>
<ul>
<div class="example">For eg:</p>
<p>&lt;?php<br />
$conn = mysql_connect(&#8221;localhost&#8221;,&#8221;tutor&#8221;,&#8221;tutor123&#8243;);<br />
if (!$conn)<br />
{<br />
die(&#8217;Could not connect: &#8216; . mysql_error());<br />
}<br />
mysql_select_db(&#8221;my_db&#8221;, $conn);<br />
$result = mysql_query(&#8221;SELECT * FROM Persons&#8221;);<br />
while($row = mysql_fetch_array($result))<br />
{<br />
echo $row['Country'] . &#8221; &#8221; . $row['Capital'];<br />
echo &#8220;&lt;br /&gt;&#8221;;<br />
}<br />
mysql_close($conn);<br />
?&gt;</p></div>
</ul>
<p>The example above stores the data returned by the mysql_query() function in the $result variable.</p>
<p>Next, we use the mysql_fetch_array() function to return the first row from the recordset as an array. Each call to mysql_fetch_array() returns the next row in the recordset. The while loop loops through all the records in the recordset. To print the value of each row, we use the PHP $row variable.</p>
<ul>
<div class="example">Output:</p>
<p>Zimbabwe	Harare<br />
Poland	Warsaw</p></div>
</ul>
<p><strong>Display the Result in an HTML Table</strong></p>
<p>The following example selects the same data as the example above, but will display the data in an HTML table:</p>
<ul>
<div class="example">&lt;?php<br />
$conn= mysql_connect(&#8221;localhost&#8221;,&#8221;tutor&#8221;,&#8221;tutor123&#8243;);<br />
if (!$con)<br />
{<br />
die(&#8217;Could not connect: &#8216; . mysql_error());<br />
}<br />
mysql_select_db(&#8221;my_db&#8221;, $conn);<br />
$result = mysql_query(&#8221;SELECT * FROM Country&#8221;);<br />
echo &#8220;&lt;table border=&#8217;1&#8242;&gt;<br />
&lt;tr&gt;<br />
&lt;th&gt;Country&lt;/th&gt;<br />
&lt;th&gt;Capital&lt;/th&gt;<br />
&lt;/tr&gt;&#8221;;<br />
while($row = mysql_fetch_array($result))<br />
{<br />
echo &#8220;&lt;tr&gt;&#8221;;<br />
echo &#8220;&lt;td&gt;&#8221; . $row['Country'] . &#8220;&lt;/td&gt;&#8221;;<br />
echo &#8220;&lt;td&gt;&#8221; . $row['Capital'] . &#8220;&lt;/td&gt;&#8221;;<br />
echo &#8220;&lt;/tr&gt;&#8221;;<br />
}<br />
echo &#8220;&lt;/table&gt;&#8221;;<br />
mysql_close($con);<br />
?&gt;</div>
</ul>
<ul> Output:</p>
<table border="1" cellpadding="5" width="50%">
<tbody>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Zimbabwe</td>
<td>Harare</td>
</tr>
<tr>
<td>Poland</td>
<td>Warsaw</td>
</tr>
</tbody>
</table>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/php-tutorial/php-mysql-select/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inserting Data From a PHP Form</title>
		<link>http://www.goweb99.com/blog/php-tutorial/inserting-data-from-a-php-form/</link>
		<comments>http://www.goweb99.com/blog/php-tutorial/inserting-data-from-a-php-form/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 09:46:44 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[inserting form data]]></category>
		<category><![CDATA[inserting values from php form]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=695</guid>
		<description><![CDATA[The most interesting part of a web application is that you can use dayabase to fill the form data and vice versa. This is the most useful part also, as it increases the user interactivity and helps is realizing many functions like filling up a form online.


For eg:
&#60;html&#62;
&#60;body&#62;
&#60;form action=&#8221;insert.php&#8221; method=&#8221;post&#8221;&#62;
Country: &#60;input type=&#8221;text&#8221; name=&#8221;country&#8221; /&#62;
Capital: &#60;input [...]]]></description>
			<content:encoded><![CDATA[<p>The most interesting part of a web application is that you can use dayabase to fill the form data and vice versa. This is the most useful part also, as it increases the user interactivity and helps is realizing many functions like filling up a form online.</p>
<ul>
<div class="example">
For eg:</p>
<p>&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;form action=&#8221;insert.php&#8221; method=&#8221;post&#8221;&gt;<br />
Country: &lt;input type=&#8221;text&#8221; name=&#8221;country&#8221; /&gt;<br />
Capital: &lt;input type=&#8221;text&#8221; name=&#8221;capital&#8221; /&gt;<br />
&lt;input type=&#8221;submit&#8221; /&gt;<br />
&lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></div>
</ul>
<p>When a user clicks the submit button in the HTML form in the example above, the form data is sent to &#8220;AddValues.php&#8221;.</p>
<p>The &#8220;AddValues.php&#8221; file connects to a database, and retrieves the values from the form with the PHP $_POST variables.Then, the mysql_query() function executes the INSERT INTO statement, and a new record will be added to the &#8220;Country&#8221; table.</p>
<ul>
<div class="example">
AddValues.php:</p>
<p>&lt;?php<br />
$con = mysql_connect(&#8221;localhost&#8221;,&#8221;tutor&#8221;,&#8221;tutor123&#8243;);<br />
if (!$conn)<br />
{<br />
die(&#8217;Could not connect: &#8216; . mysql_error());<br />
}<br />
mysql_select_db(&#8221;my_db&#8221;, $conn);<br />
$sql=&#8221;INSERT INTO Country (Country, Capital)<br />
VALUES(&#8217;$_POST[country]&#8216;,&#8217;$_POST[capital]&#8216;)&#8221;;<br />
if (!mysql_query($sql,$con))<br />
{<br />
die(&#8217;Error: &#8216; . mysql_error());<br />
}<br />
echo &#8220;Record added successfully&#8221;;<br />
mysql_close($conn)<br />
?&gt;</p></div>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/php-tutorial/inserting-data-from-a-php-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP MySQL Inserting Values in Table</title>
		<link>http://www.goweb99.com/blog/php-tutorial/php-mysql-inserting-values-in-table/</link>
		<comments>http://www.goweb99.com/blog/php-tutorial/php-mysql-inserting-values-in-table/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 09:32:02 +0000</pubDate>
		<dc:creator>tutor</dc:creator>
				<category><![CDATA[PHP Tutorial]]></category>
		<category><![CDATA[INSERT INTO]]></category>
		<category><![CDATA[inserting values in table]]></category>
		<category><![CDATA[MySQL INSERT INTO]]></category>

		<guid isPermaLink="false">http://www.goweb99.com/blog/?p=692</guid>
		<description><![CDATA[After creating a table you will need to insert records. You can use the INSERT INTO statement to add records to a database table.
There are two different forms to write this statement. The first form doesn&#8217;t specify the column names where the data will be inserted, only their values:

INSERT INTO table_name VALUES (value1, value2, value3,&#8230;)
The [...]]]></description>
			<content:encoded><![CDATA[<p>After creating a table you will need to insert records. You can use the INSERT INTO statement to add records to a database table.</p>
<p>There are two different forms to write this statement. The first form doesn&#8217;t specify the column names where the data will be inserted, only their values:</p>
<ul>
INSERT INTO table_name VALUES (value1, value2, value3,&#8230;)</ul>
<p>The second form specifies both the column names and the values to be inserted:</p>
<ul>
INSERT INTO table_name (column1, column2, column3,&#8230;)<br />
VALUES (value1, value2, value3,&#8230;)</ul>
<ul>
<div class="example">
For eg:</p>
<p>&lt;?php<br />
$conn = mysql_connect(&#8221;localhost&#8221;,&#8221;tutor&#8221;,&#8221;tutor123&#8243;);<br />
if (!$conn)<br />
{<br />
die(&#8217;Could not connect: &#8216; . mysql_error());<br />
}<br />
mysql_select_db(&#8221;my_db&#8221;, $conn);<br />
mysql_query(&#8221;INSERT INTO Persons (Country, Capital)<br />
VALUES (&#8217;India&#8217;, &#8216;New Delhi&#8217;)&#8221;);<br />
mysql_query(&#8221;INSERT INTO Persons (Country, Capital)<br />
VALUES (&#8217;United States of America&#8217;, &#8216;Washington D.C.&#8217;)&#8221;);<br />
mysql_query(&#8221;INSERT INTO Persons (Country, Capital)<br />
VALUES (&#8217;Zimbabwe&#8217;, &#8216;Harare&#8217;)&#8221;);<br />
mysql_query(&#8221;INSERT INTO Country (Country, Capital)<br />
VALUES (&#8217;Poland&#8217;, &#8216;Warsaw&#8217;)&#8221;);<br />
mysql_close($conn);<br />
?&gt;</p></div>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.goweb99.com/blog/php-tutorial/php-mysql-inserting-values-in-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
