<?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>Webcodez - The database of web programming tutorials &#187; fundamentals</title>
	<atom:link href="http://www.webcodez.net/tag/fundamentals/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webcodez.net</link>
	<description>Archive of tutorials on php,mysql,Javascript,html,css and other coding languages as well as code-snippets.</description>
	<lastBuildDate>Tue, 18 May 2010 16:43:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Understanding HTML</title>
		<link>http://www.webcodez.net/html-css/understanding-html/</link>
		<comments>http://www.webcodez.net/html-css/understanding-html/#comments</comments>
		<pubDate>Tue, 18 May 2010 16:43:49 +0000</pubDate>
		<dc:creator>antiSigma</dc:creator>
				<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html faq]]></category>

		<guid isPermaLink="false">http://www.webcodez.net/?p=501</guid>
		<description><![CDATA[What Is HTML?
HTML or Hypertext Markup Language, is the predominant language in  which most Internet web pages are based.  HTML accomplishes a number of  tasks via a web page, including describing the structure of text based  information to be displayed within the page (font sizes, text colors and  formats, etc.), providing [...]]]></description>
			<content:encoded><![CDATA[<p>What Is HTML?</p>
<p>HTML or Hypertext Markup Language, is the predominant language in  which most Internet web pages are based.  HTML accomplishes a number of  tasks via a web page, including describing the structure of text based  information to be displayed within the page (font sizes, text colors and  formats, etc.), providing a means for the user to interact with the  site via web forms, and embedding images and other types media for  display to the user.</p>
<p>When an HTML page is provided to a user’s web browser over the  Internet, the web browser will “translate” the HTML code into the format  that will be displayed to the user.<br />
HTML is written in the form of  labels (known as tags).  Each tag includes an “open” tag and a “close”  tag, and the text that is contained within the opening and closing  tags.  For example, text can be made bold by using the &lt;b&gt; and  &lt;/b&gt; tag pair, so that the following HTML code will display the  bold text word “Hello” in the user’s web browser.<br />
&lt;b&gt;<br />
Hello<br />
&lt;/b&gt;<br />
HTML  pages can also incorporate or embed the code for one or more “scripting  languages”, including JavaScript, PHP, CGI, and ASP.Net.</p>
<p>What Can HTML Do for Me?</p>
<p>HTML provides the basic structure for your website, so it’s the  foundation for your business getting its message to customers and  potential customers.  When you understand the basic principles of HTML,  you can begin to format your web pages to have a more unique and in-  house appearance.  Brand recognition is important in business, and a  little HTML coding can change a template style web page into something  that is unique and recognizable.  In addition to displaying advertising  copy, pictures, brochures and the like, you can also:</p>
<p>· Provide users with a feedback form to submit basic information  to you through the website.<br />
· Generate an email<br />
· Offer a  Guestbook</p>
<p>How Do I Learn HTML?</p>
<p>As you might suspect, there is a seemingly endless supply of  web-based tutorials and instructional materials for learning about  HTML.  There are a number of Internet-based tutorials to get you  started, and to instruct you on any particular detail or HTML feature  that you’re interested in.</p>
<p>Another way to “learn” HTML is simply to create you website using  a web-authoring program, and examine the HTML code behind it.  We’ll  talk about a few of the leading web-authoring programs later in this  article.</p>
<p>Do I Need To Learn It?</p>
<p>Strictly speaking, you don’t need to become an HTML expert to  build and administer your businesses website.  Many of the most popular  tools for website construction include powerful capabilities (including  many that most websites may never utilize).  As an added benefit, some  of these programs are available at no cost.</p>
<p>Since the HTML that serves as the backbone of a website is  basically just text, any text editor (including Microsoft’s Notepad) can  be used to create a website.  Even though writing HTML code directly in  a text editor can eventually help you to better understand what’s going  on “under the hood”, spending the time necessary to become a hardcore  HTML coder might simply not be an option.</p>
<p>In contrast, there are also popular programs that make it much  easier to create your website layout and design through graphical user  interface.  These programs do the heavy lifting, and will automatically  assemble the HTML code based on the design you make.</p>
<p>Dreamweaver</p>
<p>Adobe’s Dreamweaver is one of the leading commercial web design  software packages available today.  Dreamweaver has a reputation within  in the web design community as being very rich in features, and one that  generates very “clean” or more standards-compliant code.  (This means  that, in theory, the Dreamweaver code should run more predictably on a  broader range of web browsers.)  Dreamweaver also has strong support for  CSS, JavaScript, XML, and a variety of other functionalities that are  commonly used on “higher end” websites.  In addition, Dreamweaver has  tight integration with Adobe’s other design programs, including  Photoshop and Flash.  This can be a time-saver if you are using (or  decide to use) those other programs.</p>
<p>On the other hand, Dreamweaver is expensive, compared to other  commercial options.  In addition, many feel that because there are so  many features and functions available in the program, it can be  intimidating for new users and designers.</p>
<p>Expression Web</p>
<p>Microsoft’s Expression Web (the successor to the venerable  FrontPage software) is Microsoft’s web authoring tool and is considered  to be one of the leading web design tool available today.</p>
<p>Expression Web has many (if not most) of the same tools as are  available in Dreamweaver, and boasts strong integration with Microsoft’s  other design and infrastructure products, such as Visual Studio,  SharePoint, and the Office suite of products.  In addition, Expression  Web’s menu structures and look-and-feel will be familiar to users of  other Microsoft Office products, which can make it easier for those  already accustomed to Microsoft products.</p>
<p>Note, however, that the source code that Expression Web generates  is sometimes not as clean as that created by Dreamweaver (or coded  directly into HTML using a simple text editor), so this may result in  some problems (or at least some additional time required) if you decide  to use Dreamweaver to modify a page that was created in Expression Web.   In addition, some page elements (such as tables) can require additional  work if created in one program and then edited in another.</p>
<p>Nvu</p>
<p>For those who want to create relatively simple websites, without  some of the fancy features that are available with Dreamweaver and  Expression Web might wish to consider the open source product Nvu.  Nvu  has a graphical user interface like Dreamweaver and Expression Web, and  is very efficient at making much HTML coding easier and quicker.  As an  open source product, Nvu is free of charge, and relatively well  supported by its user community.</p>
<p>Web-Based Programs and Templates</p>
<p>Finally, be aware that there are a number of web-based authoring  programs (such as Homestead) and template services available.  These  options often require very little effort in terms of design and coding,  and are generally available at very reasonable prices.  Keep in mind,  however, that because most templates are or have been available to other  users, you might wind up with a design that is not unique, or doesn’t  provide your website with a sufficiently distinct identity.</p>
<p>How to Move Forward</p>
<p>At the end of the day, any web authoring tool is likely to have  both have pluses and minuses.  Before committing to license any  particular package, take a little time to try any available online or  downloadable trial versions of the package.  The key to deciding is to  identify your current and future needs, and balance this against your  budget for the project.  While choosing a particular tool won’t forever  tie you to using that same tool in the future, making a thoughtful  decision at the outset can help you to avoid spending time making  corrections and adjustments down the road.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webcodez.net/html-css/understanding-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Script Or Website</title>
		<link>http://www.webcodez.net/php-mysql/php-script-or-website/</link>
		<comments>http://www.webcodez.net/php-mysql/php-script-or-website/#comments</comments>
		<pubDate>Tue, 18 May 2010 16:26:09 +0000</pubDate>
		<dc:creator>antiSigma</dc:creator>
				<category><![CDATA[PHP & MySql]]></category>
		<category><![CDATA[basic PHP file]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php simple]]></category>

		<guid isPermaLink="false">http://www.webcodez.net/?p=485</guid>
		<description><![CDATA[Never mind the chicken or the egg. The burning philosophical question  of our cyber age is, which came first, the PHP tutorial script or the  website? You see the list of instructions that your PC follows when it  displays a website on your screen, the software in other words is a  [...]]]></description>
			<content:encoded><![CDATA[<p>Never mind the chicken or the egg. The burning philosophical question  of our cyber age is, which came first, the PHP tutorial script or the  website? You see the list of instructions that your PC follows when it  displays a website on your screen, the software in other words is a  symbolic language called PHP. Itâs called a language, but it is a  language very unlike English, whether it is US or UK or any other kind.</p>
<p>Unlike language as we humans think of it, PHP tutorial scripts are  not meant to be heard or listened too or even spoken. PHP tutorial  scripts are learnt by people in order to be written and then âreadâ  and operated by computers alone.</p>
<p>PHP tutorial scripts are strings of symbols that operate only as  pixels on screen and as digital data on your computers hard disk and on  the servers of your Internet service provider. So have you ever wondered  what happens to all those web pages, words and images when you move  away from the website?</p>
<p>I always imagine them to be like the hologram of Princess Leia in the  Star Wars movie. When you open up a website the PHP script leaps to  life in front of your eyes and just as quickly reverts to PHP encoded  script when you maneuver away from any particular site. So if nobody is  visiting your website at any given time does it exist at all? Rather it  only exists as a PHP tutorial script. That is to say PHP tutorial  scripts only exist in a symbolic world until activated and then they  only exist in a different symbolic world as long as you are looking at  them. âHelp me Obi Wan, youâre my only hope!â</p>
<p>Now you can go to PHP tutorial script websites and learn to write the  language of PHP scripts that will then generate websites of infinite  variety and designed to your PHP scripting. (Really it isnât as  difficult as becoming a Jedi knight). So hence the question that we  began with, (boy arenât you glad you started this?) which came first  the PHP tutorial script or the website?</p>
<p>Am I just contemplating my navel or does all this PHP tutorial script  talk have anything to do with real life. Well quite a lot actually.  âSearch your feelings Luke. You know itâs trueâ? You can turn a  PHP tutorial script into cash and earn a very good living as a PHP  programmer.</p>
<p>The online job site oDesk is finding that number of projects for PHP  programmers is growing faster than any other freelance sector and the  wages paid for these projects are rising faster too. ODesk also report  that âoverall, PHP demand was twice that of any other programming  language. Open source technology, led by PHP and MySQL, is by far the  skill set in highest demand today.&#8221;</p>
<p>PHP tutorial scripts are better than any other coding platform  because it is free. Very flexible and offers a huge support network of  other PHP scripters. There is an extensive library of PHP tutorial  scripts that can be tailored, are transferable and match to fit almost  any web application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webcodez.net/php-mysql/php-script-or-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Tutorials &#8211; The Roundup</title>
		<link>http://www.webcodez.net/php-mysql/php-tutorials-the-roundup/</link>
		<comments>http://www.webcodez.net/php-mysql/php-tutorials-the-roundup/#comments</comments>
		<pubDate>Tue, 18 May 2010 16:11:58 +0000</pubDate>
		<dc:creator>antiSigma</dc:creator>
				<category><![CDATA[PHP & MySql]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php simple]]></category>

		<guid isPermaLink="false">http://www.webcodez.net/php-mysql/php-tutorials-the-roundup/</guid>
		<description><![CDATA[In this article I will speak about PHP programming language and try  to make it clear for every newbie which wants to start learning php.  But, for beeing able to start learning this computer programming  language, you should start by understand what is this and what is doing.
Well, PHP is a server-side [...]]]></description>
			<content:encoded><![CDATA[<p>In this article I will speak about PHP programming language and try  to make it clear for every newbie which wants to start learning php.  But, for beeing able to start learning this computer programming  language, you should start by understand what is this and what is doing.</p>
<p>Well, PHP is a server-side programming language : server-side? means  that the code is interpreted at level of the PHP engine installed on the  web server. PHP is open-source (free at no cost). Beeing free of charge  makes it very popular and I would say easy to use.</p>
<p>Where can be used php? Everywhere on the web, and I think desktop  application can be coded too with the GTK feature but I dont know much  about it so I will stop here talking about this. On the other side, for  the web application development, you can build dynamic websites,  database driven websites (for example MySQL, PostreSQL, etc.), diverse  web forms like a contact form which will insert the infos into database  system or send details entered in the form to a specified email address,  etc.</p>
<p>How do you start the ball rolling? Well, please start reading  introductory tutorials on php official website, then get a project in  mind and try finding requirements needed for this project. This is the  best way to learn : by practicing, not just reading tons of borring  tutorials.</p>
<p>Once you got a project in mind, you will definitely need a php engine to  be able to execute the code. How do you make this? Simply install a  webserver like apache, add php server to this and mysql database engine.  You&#8217;ll find a lot of documentation to help you doing this or there are a  lot of ready made packs wich includes, php, apache, phpmyadmin, mysql,  etc for example easyphp web server or xampp. They&#8217;re free and easy to  install.</p>
<p>The second thing is to register at specific forums, where you can get  support and help from the php gurus, because you really need fast help  when errors will occure, and by the way, trust me you&#8217;ll encounter a lot  of &#8220;strange&#8221; errors at the begining, which later will become just a  routine.</p>
<p>And lastly, do not forget to get a nice code editor with code colloring,  code auto-completion feature is very important too which will make  developing faster. My tip here is to use Zend IDE (the php company)  which is the best and includes mentioned features. Also, Adobe  Dreamweaver is not bad, you can use that too which is nice for html/css  client side scripting. I assumed that you already know html at least, it  is very recommended to know it to make things clear in programming.</p>
<p>And, for the begining this should be enough for a novice to begin to  learn php programming language at the basic level. Later, with the time  and projects which are mandatory for progress, you&#8217;ll get experience and  will advance maybe to OOP (object oriented programming) which is  another thing important.<br />
Good luck in learning!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webcodez.net/php-mysql/php-tutorials-the-roundup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySql Basics &#8211; Retrieve Data</title>
		<link>http://www.webcodez.net/php-mysql/mysql-basics-retrieve-data/</link>
		<comments>http://www.webcodez.net/php-mysql/mysql-basics-retrieve-data/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 11:23:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySql]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[while loop]]></category>

		<guid isPermaLink="false">http://www.webcodez.net/?p=157</guid>
		<description><![CDATA[To retrieve data from a table of the database, we can use the mysql SELECT query. As discussed in the previous chapter, we use the mysql_query function to interactwith the database ( insert/retrieve data ). Although we&#8217;re now not going to INSERT data into the database but we&#8217;ll be using the SELECT type of query [...]]]></description>
			<content:encoded><![CDATA[<p>To retrieve data from a table of the database, we can use the mysql SELECT query. As discussed in the previous chapter, we use the mysql_query function to interactwith the database ( insert/retrieve data ). Although we&#8217;re now not going to INSERT data into the database but we&#8217;ll be using the SELECT type of query to retrieve data from the database ( from a certain table ). This type of query looks like this (basic structure):</p>
<pre name="code" class="php:nogutter">
mysql_query("SELECT field_name FROM table_name WHERE clause");
</pre>
<p>The 2 main things that need to be set are the field(s) you want to select the values of, and from what table you want to do this. Though if you only set these argruments, then it would retrieve the values of the fields in that table ( the fields you set ) for ALL rows it has. So if you only want to get the field(s)&#8217;s value of a specific row(s), you can be more specific by adding a &#8216;WHERE clause&#8217; part. Fill in any condition for the &#8216;clause&#8217; part. For example:</p>
<p>Example table &#8216;users&#8217;:<br />
[TABLE=2]</p>
<p>Example query:</p>
<pre name="code" class="php:nogutter">
$usernames = mysql_query("SELECT username FROM users WHERE country = 'USA'");
</pre>
<p>Say you&#8217;ve got a table called &#8216;users&#8217; which contains all user accounts of a website. A query smilar to this could be used to retrieve the value of the field &#8216;username&#8217; of all rows ( user accounts in this case ) that have the value ´USA´ for the field ´country´. In other words: in this example it would select all usernames of users who have set their country to &#8216;USA&#8217;.</p>
<p>In this example it would select the first and second row, which have the country set to USA. So it would select the username &#8216;Admin&#8217; and the username &#8216;Test2&#8242;. Which can be stored into an array using the function mysql_fetch_assoc(mysql query here).</p>
<p>However it only puts one row into an array a time. So it only selects 1 row per time, but say we want to show all rows ( usernames of them ) then we will need to use the while loop and the mysql_fetch_assoc function.</p>
<pre name="code" class="php:nogutter">
$usernames = mysql_query("SELECT username FROM users WHERE country = 'USA'");

while($user_row = mysql_fetch_assoc($usernames)) {

    echo "Row (user) match found:".$user_row['username']."

";

}
</pre>
<p>Ok let&#8217;s have a look into this loop. What it basicly does, is execute the mysql query in $usernames and retrieve the data of the row it finds ( in this case the value of the field &#8216;username&#8217; of that certain row it found ). But as it can only select one row a time, it will keep doing it for each row it finds. So when it finds a row that matches the query, it will put the data into the variable $user_row as we called it. Then execute the while loop code ( echo&#8217;s some text with the username found ) and repeats it for each row it find.In this case there were 2 rows that matched the query. So for each of the rows the data will be put in the $user_row variable and the while loop will be executed for each row seperated.</p>
<p>When a row is found then the values of the fields it selected in the query ( username only in this case ) will be stored into $user_row['field_name']. In this case we selected the field &#8216;username&#8217; so the value of it will be stored in the variable $user_row['username']. If you need to select more than one field, for one row each field&#8217;s value will be stored into its own sub-variable too like: $user_row['field_name'].</p>
<p>Then we&#8217;ve come to the output of this code, which is:</p>
<blockquote><p>Row (user) match found: Admin<br />
Row (user) match found: Test2</p></blockquote>
<p>That&#8217;s it, hope you learnt something again</p>
<p>Cheers,<br />
Admin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webcodez.net/php-mysql/mysql-basics-retrieve-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySql Basics &#8211; Insert Data</title>
		<link>http://www.webcodez.net/php-mysql/mysql-basics-insert-data/</link>
		<comments>http://www.webcodez.net/php-mysql/mysql-basics-insert-data/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 11:20:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySql]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[Insert Data]]></category>
		<category><![CDATA[Insert Query]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[Query]]></category>

		<guid isPermaLink="false">http://www.webcodez.net/?p=155</guid>
		<description><![CDATA[To insert data into the database, mysql queries are used. There are multiple types of mysql queries. The one to put data into the database is the INSERT query. This one inserts a new row into the database which requires the fields of a row for that table to be given a value to.
A basic [...]]]></description>
			<content:encoded><![CDATA[<p>To insert data into the database, mysql queries are used. There are multiple types of mysql queries. The one to put data into the database is the INSERT query. This one inserts a new row into the database which requires the fields of a row for that table to be given a value to.</p>
<p>A basic mysql query structure:</p>
<pre name="code" class="php:nogutter">
mysql_query("...query here..");
</pre>
<p>A basic INSERT query:</p>
<pre name="code" class="php:nogutter">
mysql_query("INSERT INTO table_name (field1, field2) VALUES ('value1', 'value2') ");
</pre>
<p>We could again use the or die(mysql_error()) function to make it show the mysql error message when an error occurs.</p>
<p>So in the above example we made it insert a new row for the table &#8216;table_name&#8217;. For that row we gave field1 the value &#8216;value1&#8242; and field2 the value &#8216;value2&#8242;.</p>
<p>Let&#8217;s have a look at an example of a table containing all user accounts (=rows):</p>
<p>Example table &#8216;users&#8217;:</p>
<p>[TABLE=1]</p>
<p>We already got one row in the table of the database, one user account. To add another one to this table we need to set values for the fields (id, )username, password, email. The ID field usually is auto_increment and primairy key, which means it&#8217;s a unique key for each row and automaticly increases for each new row that&#8217;s added and so doesn&#8217;t need to be set by ourselves. The example query would look like this ( for this table called &#8216;users&#8217; ):</p>
<pre name="code" class="php:nogutter">
$new_user = mysql_query("INSERT INTO users (username, password, email) VALUES ('testuser', 'testpassword', 'test.email@hotmail.com') ");
</pre>
<p>You see we here create a new row using the INSERT query, for the table called &#8216;users&#8217;, giving the value &#8216;testuser&#8217; to the field &#8216;username&#8217;, &#8216;testpassword&#8217; to the field &#8216;passsword&#8217; and &#8216;test.email@hotmail.com&#8217; to the field &#8216;email&#8217; for the new row we create ( representing a new user in this case ).</p>
<p>Hope you learnt something, if you have any questions, feel free to ask.</p>
<p>Cheers,<br />
Admin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webcodez.net/php-mysql/mysql-basics-insert-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySql Basics &#8211; Connect</title>
		<link>http://www.webcodez.net/php-mysql/mysql-basics-connect/</link>
		<comments>http://www.webcodez.net/php-mysql/mysql-basics-connect/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 11:17:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySql]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[Connect]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[mysql_connect]]></category>
		<category><![CDATA[mysql_select_db]]></category>

		<guid isPermaLink="false">http://www.webcodez.net/?p=153</guid>
		<description><![CDATA[MySql can be used to interact with databases: insert and retrieve data. It can come very handy when you need to save a collection of the same &#8216;kind&#8217; ( such as products or forum messages, user accounts, etc. ) and which need to be able to be edited easily. To interact with the database you [...]]]></description>
			<content:encoded><![CDATA[<p>MySql can be used to interact with databases: insert and retrieve data. It can come very handy when you need to save a collection of the same &#8216;kind&#8217; ( such as products or forum messages, user accounts, etc. ) and which need to be able to be edited easily. To interact with the database you first need to connect to the host and then select the database you want to interact with. In MySql you can use the functions mysql_connect and mysql_select_db to do so.</p>
<pre name="code" class="php:nogutter">
mysql_connect("host", "username", "password");
mysql_select_db("database");
</pre>
<p>mysql_connect is used to connect to the host, which requires a username and a password. When the user for the host requires no password, you can leave out the password. The host is usually just &#8220;localhost&#8221;, depending on your host (settings). For the username you can often use &#8220;root&#8221; as default username if there aren&#8217;t any other users made for the host.</p>
<p>mysql_select_db is pretty much straight forward I guess. You make it select the database you&#8217;re going to use. You can also use the or die(&#8220;error message here&#8221;) to make it show an error when it fails to connect. There&#8217;s a standard mysql error message which can be called by using mysql_error() function.So it&#8217;d be:</p>
<pre name="code" class="php:nogutter">
mysql_connect("localhost", "root", "mypassword")or die(mysql_error());
mysql_select_db("mydatabase")or die(mysql_error());
</pre>
<p>So when any error occurs while connecting to the host/database, the mysql error message will appear containing the error occured.</p>
<p>You can also manually check whether the connection was successfully by putitng them into variables and checking the variables:</p>
<pre name="code" class="php:nogutter">
$connect = mysql_connect("localhost", "root", "mypassword");
$db      = mysql_select_db("mydatabase");

if(!$connect) {

     die("Host connection failed");

}

if(!$db) {

    die("Database connection failed");

}

?>
</pre>
<p>Now you&#8217;re ready to use the mysql functions to interact with the database, such as mysql_query, which we&#8217;ll be discussing in the next chapter.</p>
<p>Admin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webcodez.net/php-mysql/mysql-basics-connect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GET variables</title>
		<link>http://www.webcodez.net/php-mysql/get-variables/</link>
		<comments>http://www.webcodez.net/php-mysql/get-variables/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 09:27:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySql]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.webcodez.net/?p=142</guid>
		<description><![CDATA[A second method to send user filled in data (input) from forms or just to send data through the url to another page, is the GET method. The GET method works through the url of the page, and defines the GET variables inside the url.
Example:
Url: webcodez.net/showthread.php
GET variables: none
Url: webcodez.net/showthread.php?p=23
Get variables: $_GET['p'] = 23
You see you [...]]]></description>
			<content:encoded><![CDATA[<p>A second method to send user filled in data (input) from forms or just to send data through the url to another page, is the GET method. The GET method works through the url of the page, and defines the GET variables inside the url.</p>
<p><strong>Example:</strong></p>
<blockquote><p>Url: webcodez.net/showthread.php<br />
GET variables: none<br />
Url: webcodez.net/showthread.php?p=23<br />
Get variables: $_GET['p'] = 23</p></blockquote>
<p>You see you can send GET variables through the url to a page by adding ?get_variable_name=value to the url. The GET variables given through the url will be stored in an array $_GET, which contains all GET variables like: $_GET['get_variable_name']. In the above example we set a GET variable we named &#8216;p&#8217;, so it will be stored in $_GET['p'], and we gave it the value 23, so it will become $_GET['p'] = 23. You can however also add more GET variables through the url, but therefore you need to use the &#038; sign.</p>
<p><strong>Example:</strong></p>
<blockquote><p>Url: webcodez.net/editpost.php?do=updatepost&#038;postid=22<br />
GET variables: $_GET['do'] = &#8220;updatepost&#8221; and $_POST['id'] = 22</p></blockquote>
<p>In these examples the GET variables are used to define what thread of the forums to show, or what thread to edit. GET variables can so be very usefully when one page is used to complete an action that can be used for multiple things ( in this case multiple threads ).<br />
Let&#8217;s make our own file that shows all GET variables:</p>
<p><strong>File: getvars.php</strong></p>
<pre name="code" class="php:nogutter">&lt;?php
foreach($_GET as $name => $value) {
"GET variable '".$name."' = ".$value."\n";
}
?></pre>
<p>This file simply shows all GET variables, showing their names and values. You can try it out by opening the file. One example of the output when giving it some GET variables through the url.</p>
<p><strong>Example:</strong></p>
<blockquote><p>Url: getvars.php?a=10&#038;b=4&#038;c=7<br />
GET variables: $_GET['a'] = 10, $_GET['b'] = 4 and $_GET['c'] = 7<br />
Output of the file:<br />
GET variable &#8216;a&#8217; = 10<br />
GET variable &#8216;b&#8217; = 4<br />
GET variable &#8216;c&#8217; = 7</p></blockquote>
<p>Cheers,<br />
Admin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webcodez.net/php-mysql/get-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>POST Variables</title>
		<link>http://www.webcodez.net/php-mysql/post-variables/</link>
		<comments>http://www.webcodez.net/php-mysql/post-variables/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 15:05:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySql]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.webcodez.net/?p=124</guid>
		<description><![CDATA[When you create forms, you can either use the POST or GET method. In this chapter I&#8217;ll be explaining the POST method, in which the data is put into POST variables. POST variables are just like normal arrays which contain a certain amount of (sub-)variables. Once a form is submitted, for each form field one [...]]]></description>
			<content:encoded><![CDATA[<p>When you create forms, you can either use the <strong>POST </strong>or GET method. In this chapter I&#8217;ll be explaining the <strong>POST </strong>method, in which the data is put into POST variables. POST variables are just like normal arrays which contain a certain amount of (sub-)variables. Once a form is submitted, for each form field one sub-variable will be created for the array POST, the name of the sub-variable (index) will be equal to the name of the field. The value of the sub-variable will be equal to the value of the form field ( what the user filled in or the default value otherwise, if set ). So let&#8217;s start with creating a form that uses this POST method.</p>
<p><strong>Example:</strong></p>
<pre name="code" class="html:nogutter">
<form method="POST" action="handle_file.php">
... form fields ...
</form>
</pre>
<p>We simply put <strong>method=&#8221;POST&#8221; </strong>to the form tag, to make it use this method. The action here is set to some “handle_file.php&#8221;, could as well be set to any file or even the same file. It&#8217;s the file it will send the data ( using the POST method, in POST variables so ) to and go to when the form is submitted. Let&#8217;s add an example form field and submit button.</p>
<p><strong>Example:</strong></p>
<pre name="code" class="html:nogutter">
<form method="POST" action="handle_file.php">
<input type="text" name="username">
<input type="submit" name="submit" value="Post!">
</form>
</pre>
<p>In this case, once the user submits the form by clicking on the submit button, the text filled in in the field ‘username&#8217; ( the first input field with name=&#8217;username&#8217; ), will be put into the variable $_POST[‘username']. The same goes for all input fields. All values of the input fields will be stored into a variable $_POST[‘field_name_here'] and sent to the action file. Let&#8217;s use this to greet the user when he fills in his username and submits it:<br />
<strong><br />
File: form.php</strong></p>
<pre name="code" class="html:nogutter">
<form method="POST" action="handle_file.php">
<input type="text" name="username">
<input type="submit" name="submit" value="Post!">
</form>
</pre>
<p><strong>File: handle_file.php</strong></p>
<pre name="code" class="php:nogutter">&lt;?php
if(!empty($_POST['username']))
    echo "Hi there ".$_POST['username']."!";
 ?></pre>
<p>What we basicly done here is check if the field username is not empty, as the value of it would be stored into $_POST[‘username'] once the form has been submitted. So we actually check 2 things by checking whether it&#8217;s not empty. We check if the form has been submitted at all, and we check whether the input field with the name username has not been left blank. Then we use the value of it ( the username the user filled in ) to greet the user with a simple greeting.<br />
That&#8217;s it, if you have any further questions about this chapter ( POST variables ), feel free to ask.</p>
<p>Cheers,<br />
Admin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webcodez.net/php-mysql/post-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arrays</title>
		<link>http://www.webcodez.net/php-mysql/arrays/</link>
		<comments>http://www.webcodez.net/php-mysql/arrays/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 10:37:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySql]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.webcodez.net/?p=122</guid>
		<description><![CDATA[In PHP you can also create special variables called arrays. They can be used to store multiple values into in multiple &#8217;sub-variables&#8217; as I like to call them, which each have its own index (&#8216;name&#8217;) and value. So they can contain a collection of multiple variables. An array can be written in 2 different ways [...]]]></description>
			<content:encoded><![CDATA[<p>In PHP you can also create special variables called arrays. They can be used to store multiple values into in multiple &#8217;sub-variables&#8217; as I like to call them, which each have its own index (&#8216;name&#8217;) and value. So they can contain a collection of multiple variables. An array can be written in 2 different ways which are both exactly the same:</p>
<p><strong>Example 1</strong></p>
<pre name="code" class="php:nogutter">$array_variable_name = array("index_name" => "value",
                   "index_name2" => "value2");</pre>
<p><strong>Example 2</strong></p>
<pre name="code" class="php:nogutter">$array_variable_name["index_name"] = "value";
$array_variable_name["index_name2"] = "value2";</pre>
<p>However when you need to add another &#8217;sub-variable&#8217; to the array, you should use the second method. That method just defines a sub-variable of the array (adds it to the array) while the first method defines the array with ALL sub-variables it should contain.</p>
<p>Let&#8217;s compare them with normal variables by showing a way how you could define 2 variables, and how you could define them but then put together in an array.</p>
<p>Variables seperated:</p>
<pre name="code" class="php:nogutter">$var_name = "var value";
$var_name2 = "var value2";</pre>
<p>Array containing the variables:</p>
<pre name="code" class="php:nogutter">$array_name['var_name'] = "var value";
$array_name['var_name2'] = "var value2";</pre>
<p>To echo a variable of an array, you can just use the echo method:</p>
<pre name="code" class="php:nogutter">echo $array['var'];</pre>
<p>Although you can not echo an array itself (as an array contains multiple sub-variables and so multiple values, so it doesn&#8217;t know which sub-variable&#8217;s value to display/use).<br />
You can however use the print_r function to display a full array with all its sub-variables and values.</p>
<pre name="code" class="php:nogutter">print_r($array);</pre>
<p>One more example of an array and the outputs:</p>
<pre name="code" class="php:nogutter">$product_prices = array("tv" => 599.95,
              "computer" => 899.95,
                         "notebook" => 999.999
                      );

echo $product_prices["tv"]; //returns: 599.95

echo $product_prices["computer"]; //returns: 899.95
echo $product_prices["notebook"]; //returns 999.999
//we can also change the value of a sub-variable from the array and display the new value
$product_prices["notebook"] = 799.999;
echo $product_prices["notebook"]; //now returns: 799.999</pre>
<p>An array can as well contain ANOTHER array. </p>
<p><strong>Example:</strong></p>
<pre name="code" class="php:nogutter">
&lt;?php

$products[1] = array("name" => "tv", "price" => 599.95, "available" => "yes");
$products[2] = array("name" => "computer", "price" => "899.95", "available" => "no");

foreach( $products as $number => $sub_array ) {

   echo "Product #{$number}: ";

   foreach ( $sub_array as $key => $value) {

          echo $key.": ".$value." ";

   }

   echo "&lt;p>";

}

?>
</pre>
<p>The array $products now contains 2 other arrays. One array that contains sub-variables &#8216;name&#8217;, &#8216;price&#8217; and &#8216;available&#8217;, and a second array that contains those sub-variables as well but then for another product ( other values for it ). The value of the arrays and sub-variables could be written like this:</p>
<pre name="code" class="php:nogutter">
//$products = array(1 => array(), 2 => array();
//$products[1] = array(), $products[2] = array();
$products[1]['name'] = "tv";
$products[1]['price'] = 599.95;
$products[1]['available'] = "yes";

$products[2]['name'] = "notebook";
$products[2]['price'] = "899.95";
$products[2]['available'] = "no";
</pre>
<p>Admin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webcodez.net/php-mysql/arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Foreach Loop</title>
		<link>http://www.webcodez.net/php-mysql/foreach-loop/</link>
		<comments>http://www.webcodez.net/php-mysql/foreach-loop/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 09:57:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MySql]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[foreach loop]]></category>
		<category><![CDATA[fundamentals]]></category>
		<category><![CDATA[loops]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.webcodez.net/wordpress/?p=103</guid>
		<description><![CDATA[Note: This chapter requires you to have a basic knowledge of arrays. If you don’t know what arrays are or how they work, please first have a look at the arrays tutorial.
The foreach loop is used to get all keys and values from all indexes (&#8217;sub-variables&#8217;) of an array and handle them with your given [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Note:</strong> This chapter requires you to have a basic knowledge of arrays. If you don’t know what arrays are or how they work, please first have a look at the <strong>arrays tutorial</strong>.</p>
<p>The foreach loop is used to get all keys and values from all indexes (&#8217;sub-variables&#8217;) of an array and handle them with your given (&#8216;act&#8217;) code all one for one. A foreach loop looks like this (structure):</p>
<pre name="code" class="php:nogutter">foreach ( $array as $key => $value ) {

    ... act code ...

}</pre>
<p>The $array variable can be any array variable you want to handle and you can choose any variable name for $key and $value. In these variables ($key and $value in this example) the name ($key) and value ($value) of each index (‘sub-variable’) of the array will be stored and the act code will be ran. Example:</p>
<pre name="code" class="php:nogutter">$product_prices = array("tv" => 599.95,
              "computer" => 899.95,
              "notebook" => 999.999
              );

foreach($product_prices as $prod => $price) {

    echo "Product: ".$prod." \n";
    echo "Price: ".$price." &lt;p>";

}</pre>
<p>Here we got an array with 3 indexes which indicate products (the name of the products are the<br />
&#8216;keys&#8217; of the array) with their prices (the &#8216;values&#8217; of the array). So I changed the variables $key and $value to the names $prod (product) and $price, which are in this case giving a better indication of what actually is stored into them. The output of this script is a list of the products and prices:</p>
<blockquote><p>Product: tv<br />
Price: 599.95</p>
<p>Product: computer<br />
Price: 899.95</p>
<p>Product: notebook<br />
Price: 999.999</p></blockquote>
<p>Cheers,<br />
Admin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webcodez.net/php-mysql/foreach-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
