<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6153770813942491377</id><updated>2011-04-22T05:10:06.760+05:30</updated><title type='text'>Installing PHP 5.2.3, MySql 5.0, IIS 6.0 on Windows XP</title><subtitle type='html'>Installing PHP 5.2.3, MySql 5.0, IIS 6.0 on Windows XP</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sunilhp.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6153770813942491377/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sunilhp.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sunil</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6153770813942491377.post-3733523850084861903</id><published>2008-09-06T13:38:00.000+05:30</published><updated>2008-09-06T13:42:47.110+05:30</updated><title type='text'>PHP &amp; MY SQL tutorial</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;link rel="Edit-Time-Data" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_editdata.mso"&gt;&lt;!--[if !mso]&gt; &lt;style&gt; v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} &lt;/style&gt; &lt;![endif]--&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="time"&gt;&lt;/o:smarttagtype&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="date"&gt;&lt;/o:smarttagtype&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"&gt;&lt;/o:smarttagtype&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PlaceName"&gt;&lt;/o:smarttagtype&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PlaceType"&gt;&lt;/o:smarttagtype&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"&gt;&lt;/o:smarttagtype&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if !mso]&gt;&lt;object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"&gt;&lt;/object&gt; &lt;style&gt; st1\:*{behavior:url(#ieooui) } &lt;/style&gt; &lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Wingdings; 	panose-1:5 0 0 0 0 0 0 0 0 0; 	mso-font-charset:2; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face 	{font-family:Verdana; 	panose-1:2 11 6 4 3 5 4 4 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:536871559 0 0 0 415 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	text-indent:0in; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} h1 	{margin:0in; 	margin-bottom:.0001pt; 	text-indent:0in; 	mso-line-height-alt:10.8pt; 	mso-pagination:widow-orphan; 	mso-outline-level:1; 	border:none; 	mso-border-bottom-alt:dotted #0A4369 .75pt; 	padding:0in; 	mso-padding-alt:0in 0in 0in 0in; 	font-size:21.5pt; 	font-family:"Times New Roman"; 	color:#0A4369; 	letter-spacing:-1.5pt; 	font-weight:bold;} h2 	{mso-style-next:Normal; 	margin-top:12.0pt; 	margin-right:0in; 	margin-bottom:3.0pt; 	margin-left:0in; 	text-indent:0in; 	mso-pagination:widow-orphan; 	page-break-after:avoid; 	mso-outline-level:2; 	font-size:14.0pt; 	font-family:Arial; 	font-weight:bold; 	font-style:italic;} a:link, span.MsoHyperlink 	{mso-ansi-font-size:11.0pt; 	mso-bidi-font-size:11.0pt; 	color:black; 	font-weight:normal; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} p 	{mso-margin-top-alt:auto; 	margin-right:0in; 	mso-margin-bottom-alt:auto; 	margin-left:0in; 	text-indent:18.75pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} pre 	{margin:0in; 	margin-bottom:.0001pt; 	text-indent:0in; 	mso-pagination:widow-orphan; 	tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; 	font-size:10.0pt; 	font-family:"Courier New"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:.25in 1.25in 27.0pt 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:122040507; 	mso-list-template-ids:-2095533888;} @list l0:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l1 	{mso-list-id:202791866; 	mso-list-template-ids:1633596978;} @list l1:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l2 	{mso-list-id:266892598; 	mso-list-template-ids:-245338006;} @list l2:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l3 	{mso-list-id:334039500; 	mso-list-template-ids:577020812;} @list l3:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l4 	{mso-list-id:401486897; 	mso-list-template-ids:-576807600;} @list l4:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l5 	{mso-list-id:598024244; 	mso-list-template-ids:1381821994;} @list l5:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l6 	{mso-list-id:614140766; 	mso-list-template-ids:-1977738050;} @list l6:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l7 	{mso-list-id:662855303; 	mso-list-template-ids:911895196;} @list l7:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l8 	{mso-list-id:764811672; 	mso-list-template-ids:727739328;} @list l8:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l9 	{mso-list-id:832185521; 	mso-list-template-ids:-1373050056;} @list l9:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} @list l10 	{mso-list-id:839858139; 	mso-list-template-ids:-42437674;} @list l10:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l11 	{mso-list-id:843323668; 	mso-list-template-ids:1848920672;} @list l11:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l12 	{mso-list-id:1131168224; 	mso-list-template-ids:-665301768;} @list l12:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l13 	{mso-list-id:1188451918; 	mso-list-template-ids:1765195722;} @list l13:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l14 	{mso-list-id:1323389027; 	mso-list-template-ids:1417836030;} @list l14:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l15 	{mso-list-id:1363555653; 	mso-list-template-ids:-769081222;} @list l15:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l16 	{mso-list-id:1517697700; 	mso-list-template-ids:-706162558;} @list l16:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l17 	{mso-list-id:1891307297; 	mso-list-template-ids:1238767408;} @list l17:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l18 	{mso-list-id:2043287717; 	mso-list-template-ids:693276294;} @list l18:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l19 	{mso-list-id:2085226789; 	mso-list-template-ids:625760848;} @list l19:level1 	{mso-level-number-format:image; 	list-style-image:url("PicExportError"); 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	mso-ansi-font-size:10.0pt; 	font-family:Symbol;} @list l20 	{mso-list-id:2091147857; 	mso-list-template-ids:212486700;} @list l20:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;PHP / MySQL Tutorial&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;MySQL is currently the most popular open source database server in existence. On top of that, it is very commonly used in conjunction with PHP scripts to create powerful and dynamic server-side applications.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!--// &lt;![CDATA[ /* openads=http://tizag.com/oads/www/delivery bannerid=21 zoneid=15 source= */ // ]]&gt; --&gt; &lt;/script&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; //2007-05-21: NContent MySQL google_ad_channel = "9971219636"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "3D81EE"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;script src="http://tizag.com/oads/www/delivery/ag.php" type="text/javascript"&gt; &lt;/script&gt;MySQL has been criticized in the past for not supporting all the features of other popular and more expensive DataBase Management Systems. However, MySQL continues to improve with each release (currently version 5), and it has become widely popular with individuals and businesses of many different sizes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;What is a Database?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;A database is a structure that comes in two flavors: a flat database and a relational database. A relational database is much more oriented to the human mind and is often preferred over the gabble-de-gook flat database that are just stored on hard drives like a text file. MySQL is a relational database. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;In a relational structured database there are tables that store data. The columns define which kinds of information will be stored in the table. An individual column must be created for each type of data you wish to store (i.e. Age, Weight, Height). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;On the other hand, a row contains the actual values for these specified columns. Each row will have 1 value for each and every column. For example a table with columns (Name, Age, Weight-lbs) could have a row with the values (Bob, 65, 165). If all this relational database talk is too confusing, don't despair. We will talk about and show a few examples in the coming lessons. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Why Use a Database?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Databases are most useful when it comes to storing information that fits into logical categories. For example, say that you wanted to store information of all the employees in a company. With a database you can group different parts of your business into separate tables to help store your information logically. Example tables might be: Employees, Supervisors, and Customers. Each table would then contain columns specific to these three areas. To help store information related to each employee, the Employees table might have the following columns: Hire, Date, Position, Age, and Salary. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Learn MySQL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Before you begin this tutorial you should have a basic knowledge of the information covered in our &lt;a href="http://www.tizag.com/phpT/"&gt;&lt;span style="font-size: 8.5pt;"&gt;PHP&lt;/span&gt;&lt;/a&gt; and &lt;a href="http://www.tizag.com/htmlT/"&gt;&lt;span style="font-size: 8.5pt;"&gt;HTML&lt;/span&gt;&lt;/a&gt; tutorials.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This tutorial focuses heavily on using MySQL in a PHP environment. It is aimed at teaching those who have web hosts with PHP and MySQL already installed. If you are unsure, please contact your web host.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Setup Guide&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The easiest way to experiment with MySQL and PHP is to purchase some space on a shared web host. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Although you can set up MySQL manually on your home PC, it can be rather difficult for a beginner to do, and would require more than a few lessons! If you think you've got what it takes, or you're just mentally unstable, head on over to &lt;a href="http://www.mysql.com/"&gt;&lt;span style="font-size: 8.5pt;"&gt;MySQL.com&lt;/span&gt;&lt;/a&gt; for more information on installing MySQL yourself.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Setting Up MySQL in CPanel&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;There are many different types of control panels that your shared hosting provider may have. This tutorial assumes that you are using the most popular, &lt;a href="http://www.cpanel.net/"&gt;&lt;span style="font-size: 8.5pt;"&gt;CPanel&lt;/span&gt;&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;First, find the link that allows you to administer MySQL. Within CPanel the icon is labeled &lt;i&gt;MySQL Databases&lt;/i&gt;. Once there, you will need to do the following before you can start using MySQL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Create a new database &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Create a new user with password &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Assign the user to the database &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you have problems with this steps, seek help from your web hosting provider or ask a question in the &lt;a href="http://forums.tizag.com/"&gt;&lt;span style="font-size: 8.5pt;"&gt;Tizag Forums&lt;/span&gt;&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Helpful Tool - phpMyAdmin!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Also supplied by most hosting services is &lt;a href="http://www.phpmyadmin.net/home_page/index.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;phpMyAdmin &lt;/span&gt;&lt;/a&gt;(you can also install it anywhere you want, as it's open source and free). This tool will allow you to view all the MySQL database, tables, and entries, as well as perform SQL queries remotely through a web browser.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Although we will be teaching how to create databases, tables and all other MySQL tasks through PHP, we encourage you to learn about phpMyAdmin. It's easy-to-use interface will allow you to do many common MySQL tasks quickly and easily, saving you many beginner headaches and helping you understand what's going on in a more visual manner. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Admin&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This lesson covers the different options you have available to you for administering your MySQL service after it is successfully installed. If you already have that base covered feel free to skip on to the next lesson.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Command Line&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you are an old-school programmer that has no need for a graphical user interface, then you can simply use any command line interface to execute MySQL queries. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Those of you with MySQL installed on your Microsoft Windows operating system can reach the command line by going to the Start Menu and choosing "&lt;b&gt;Run&lt;/b&gt;...". Type the keyword "&lt;b&gt;cmd&lt;/b&gt;" into the text field and press &lt;b&gt;Enter&lt;/b&gt; to launch Window's command line interface. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL GUI&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;With so many free MySQL administration tools available, many developers favor these free Graphical User Interfaces over the command line. The most popular options include:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;a href="http://www.phpmyadmin.net/"&gt;&lt;span style="font-size: 8.5pt;"&gt;phpMyAdmin&lt;/span&gt;&lt;/a&gt; - A popular web interface that is included with almost every type of Shared, Virtual or Dedicated hosting solution. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;a href="http://www.mysql.com/products/tools/administrator/"&gt;&lt;span style="font-size: 8.5pt;"&gt;MySQL Administrator&lt;/span&gt;&lt;/a&gt; - A powerful tool developed by the folks at MySQL.com. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;a href="http://www.navicat.com/"&gt;&lt;span style="font-size: 8.5pt;"&gt;Navicat&lt;/span&gt;&lt;/a&gt; - A purchasable MySQL admin tool for Windows, Mac and Linux. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL phpMyAdmin&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;As previously mentioned, the very popular &lt;a href="http://www.phpmyadmin.net/home_page/"&gt;&lt;span style="font-size: 8.5pt;"&gt;phpMyAdmin&lt;/span&gt;&lt;/a&gt; tool should come with your web hosting plan.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Administrator&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This tool comes from the creators of MySQL, so you can be assured they have a solid understanding of database optimization and stability for power users. There are currently two versions of MySQL Administrator: 1.0 and 1.1. MySQL.com recommends you use 1.1 if your MySQL installation is 4.0, 4.1 or 5.0. Read more about the &lt;a href="http://www.mysql.com/products/tools/administrator/"&gt;&lt;span style="font-size: 8.5pt;"&gt;MySQL Administrator&lt;/span&gt;&lt;/a&gt; on MySQL.com's web site. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Navicat&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Navicat comes with a 30-day trial so you can play around and see if you feel like dropping the cash for this MySQL administration product. A brief overview of their product &lt;a href="http://www.navicat.com/product.html"&gt;&lt;span style="font-size: 8.5pt;"&gt;Navicat Admin&lt;/span&gt;&lt;/a&gt; can be found on their website. The cost of this product is around $100. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Syntax&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The great thing about everything you do in MySQL is that the "code" is very easy for humans to read, as opposed to harder programming languages like C or C++. Very few special characters and symbols are required to create a MySQL query, and most queries consist entirely of English words!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Strategies to Learn MySQL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The MySQL language is not as complicated as most programming languages, so the best way to learn is with direct examples. Because this tutorial focuses on the combination of MySQL and PHP, most of the examples are ready for you to copy, paste, and run on your web server. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;CAPITALIZATION in MySQL Queries&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;There are many keywords in MySQL, and a good programming habit when using ANY of these words is to capitalize them. This helps draw them out from the rest of the code and makes them much easier to read. Below is an example of a MySQL query written in PHP that retrieves all the data from a MySQL table named "example". &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;$result = mysql_query("SELECT * FROM example") &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;That line of code is valid PHP, but it also contains valid MySQL. The text that appears between the quotations "SELECT * FROM example", is the MySQL code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;As you probably can tell "SELECT" and "FROM" are the MySQL keywords used in this query. Capitalizing them allows you to tell from a quick glance that this query selects data from a table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;You can view a complete list of MySQL keywords at &lt;a href="http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html"&gt;&lt;span style="font-size: 8.5pt;"&gt;List of Reserved MySQL Words&lt;/span&gt;&lt;/a&gt;, but don't worry about memorizing them. You could program relentlessly in MySQL for years without ever using all of the MySQL keywords. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Learn at Your Own Pace&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;When learning MySQL, it is best to take it one lesson at a time and stop when you feel frustrated. Do not worry if it takes you more than a week to finish this tutorial. If you take the time to progress slowly, you will be much more well-informed about the MySQL database system than if you rushed through it in one sitting.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Database&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;A MySQL database is nothing in itself. Rather a MySQL database is a way of organizing a group of tables. If you were going to create a bunch of different tables that shared a common theme, you would group them into one database to make the management process easier.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Creating Your First Database&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Most web hosts do not allow you to create a database directly through a PHP script. Instead they require that you use the PHP/MySQL administration tools on the web host control panel to create these databases. Create a database and assign a new user to this database. For all of our beginning examples we will be using the following information: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Server&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - localhost &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Database&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - test &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Table&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - example &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Username&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - admin &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Password&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - 1admin &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Note&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;: The table may change in the advanced lessons, but everything else will remain the same!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The server is the name of the server we want to connect to. Because all of our scripts are going to be placed on the server where MySQL is located the correct address is &lt;i&gt;localhost&lt;/i&gt;. If the MySQL server was on a different machine from where the script was running, then you would need to enter the correct url (ask your web host for specifics on this).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Your database, table, username, and password do not have to match ours. If you choose a different set of login information, remember to insert your own information when copying the scripts in this tutorial.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Status Check&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;So far, you should have created a new database and assigned a user to it. You should &lt;b&gt;not&lt;/b&gt; have created a table yet. If you are up-to-date, then continue the tutorial. We will be making our first table in an upcoming lesson.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Connect&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Before you can do anything with MySQL in PHP you must first establish a connection to your web host's MySQL database. This is done with the MySQL connect function. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL localhost&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you've been around the internet a while, you'll know that IP addresses are used as identifiers for computers and web servers. In this example of a connection script, we assume that the MySQL service is running on the same machine as the script.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;When the PHP script and MySQL are on the same machine, you can use &lt;i&gt;localhost&lt;/i&gt; as the address you wish to connect to. &lt;i&gt;localhost&lt;/i&gt; is a shortcut to just have the machine connect to itself. If your MySQL service is running at a separate location you will need to insert the IP address or URL in place of &lt;i&gt;localhost&lt;/i&gt;. Please contact your web host for more details if &lt;i&gt;localhost&lt;/i&gt; does not work.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_connect("localhost", "admin", "1admin") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "Connected to MySQL&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Connected to MySQL &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you load the above PHP script to your webserver and everything works properly, then you should see "Connected to MySQL" displayed when you view the .php page. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The mysql_connect function takes three arguments. Server, username, and password. In our example above these arguments were: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Server&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - localhost &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Username&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - admin &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Password&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - 1admin &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The "or die(mysql..." code displays an error message in your browser if --you've probably guessed it -- there is an error in processing the connection! Double-check your username, password, or server if you receive this error.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Choosing the Working Database&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;After establishing a MySQL connection with the code above, you then need to choose which database you will be using with this connection. This is done with the &lt;i&gt;mysql_select_db&lt;/i&gt; function. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_connect("localhost", "admin", "1admin") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "Connected to MySQL&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;mysql_select_db("test")&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "Connected to Database";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Connected to MySQL&lt;br /&gt;Connected to Database &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Status Check&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;So far you should have made a MySQL connection and chosen the working database. If you are up-to-date then continue the tutorial. We will be making our first table in the next lesson. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Tables&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;A MySQL table is completely different than the normal table that you eat dinner on. In MySQL and other database systems, the goal is to store information in an orderly fashion. The table gets this done by making the table up of columns and rows. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!--// &lt;![CDATA[ /* openads=http://tizag.com/oads/www/delivery bannerid=21 zoneid=15 source= */ // ]]&gt; --&gt; &lt;/script&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; //2007-05-21: NContent MySQL google_ad_channel = "9971219636"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "3D81EE"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;script src="http://tizag.com/oads/www/delivery/ag.php" type="text/javascript"&gt; &lt;/script&gt;The columns specify what the data is going to be, while the rows contain the actual data. Below is how you could imagine a MySQL table. (C = Column, R = Row)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div align="center"&gt;  &lt;table class="MsoNormalTable" style="background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;C1 (Namge)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;C2 (Age)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;C3 (Weight)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R1 C1   (John)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R1 C2 (21)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R1 C3   (120)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R2 C1 (Big   Sally)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R2 C2 (27)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R2 C3   (400)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R3 C1   (Tiny Tim)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R3 C2 (6)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R3 C3 (35)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R4 C1 (&lt;st1:place st="on"&gt;Normal&lt;/st1:place&gt; Ned)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R4 C2 (35)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;R4 C3 (160)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;We added the row and column number (R# C#) so that you can see that a row is side-to-side, while a column is up-to-down. In a real MySQL table only the value would be stored, not the R# and C#!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This table has three categories, or "columns", of data: Name, Age, and Weight. This table has four entries, or in other words, four rows. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Create Table MySQL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Before you can enter data (rows) into a table, you must first define what kinds of data will be stored (columns). We are now going to design a MySQL query to summon our table from database land. In future lessons we will be using this table, so be sure to enter this query correctly! &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_connect("localhost", "admin", "1admin") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_select_db("test") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Create a MySQL table in the selected database&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query("CREATE TABLE example(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;id INT NOT NULL AUTO_INCREMENT, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;PRIMARY KEY(id),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; name VARCHAR(30), &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt; &lt;/span&gt;age INT)")&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "Table Created!";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Table Created! &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Wow! That's a lot of code all at once! Let's get down in the dirt and figure this stuff out. We will be going through the code line by line.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'mysql_query ("CREATE TABLE example'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The first part of the &lt;i&gt;mysql_query&lt;/i&gt; told MySQL that we wanted to create a new table. The two capitalized words are reserved MySQL keywords. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The word "example" is the name of our table, as it came directly after "CREATE TABLE". It is a good idea to use descriptive names when creating a table, such as: employee_information, contacts, or customer_orders. Clear names will ensure that you will know what the table is about when revisiting it a year after you make it. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'id INT NOT NULL AUTO_INCREMENT'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Here we create a column "id" that will automatically increment each time a new entry is added to the table. This will result in the first row in the table having an &lt;i&gt;id&lt;/i&gt; = 1, the second row &lt;i&gt;id&lt;/i&gt; = 2, the third row &lt;i&gt;id&lt;/i&gt; = 3, and so on.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The column "id" is not something that we need to worry about after we create this table, as it is all automatically calculated within MySQL. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Reserved MySQL Keywords&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;:&lt;br /&gt;Here are a few quick definitions of the reserved words used in this line of code: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;INT&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - This stands for integer or whole number. 'id' has been defined to be an integer. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;NOT NULL&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - These are actually two keywords, but they combine together to say that this column cannot be null. An entry is NOT NULL only if it has some value, while something with no value is NULL. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;AUTO_INCREMENT&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - Each time a new entry is added the value will be incremented by 1. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'PRIMARY KEY (id)'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;PRIMARY KEY is used as a unique identifier for the rows. Here we have made "id" the PRIMARY KEY for this table. This means that no two ids can be the same, or else we will run into trouble. This is why we made "id" an auto-incrementing counter in the previous line of code. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'name VARCHAR(30),'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Here we make a new column with the name "name"! VARCHAR stands for "variable character". "Character" means that you can put in any kind of typed information in this column (letters, numbers, symbols, etc). It's "variable" because it can adjust its size to store as little as 0 characters and up to a specified maximum number of characters.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;We will most likely only be using this name column to store characters (A-Z, a-z). The number inside the parentheses sets the maximum number of characters. In this case, the max is 30. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'age INT,'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Our third and final column is age, which stores an integer. Notice that there are no parentheses following "INT". MySQL already knows what to do with an integer. The possible integer values that can be stored in an "INT" are -2,147,483,648 to 2,147,483,647, which is more than enough to store someone's age! &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'or die(mysql_error());'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This will print out an error if there is a problem in the table creation process.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Your Homework&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Using the MySQL administration tool that your web host has, check to see if the table was created correctly. Afterwards, try creating a few of your own, with PHP or with a MySQL administration tool, to be sure that you have gotten the hang of it. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Insert&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;When data is put into a MySQL table it is referred to as inserting data. When inserting data it is important to remember the exact names and types of the table's columns. If you try to place a 500 word essay into a column that only accepts integers of size three, you will end up with a nasty error! &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Inserting Data Into Your Table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Now that you have created your table, let's put some data into that puppy! Here is the PHP/MySQL code for inserting data into the "example" table we created in the previous lesson. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_connect("localhost", "admin", "1admin") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_select_db("test") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Insert a row of information into the table "example"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query("INSERT INTO example &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;(name, age) VALUES('Timmy Mellowman', '23' ) ") &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query("INSERT INTO example &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;(name, age) VALUES('Sandy Smith', '21' ) ") &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query("INSERT INTO example &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;(name, age) VALUES('Bobby Wallace', '15' ) ") &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "Data Inserted!";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Data Inserted! &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This code is much simpler to understand than the create table code, as will be most of the MySQL queries you will learn in the rest of this tutorial. Once again, we will cover the code line by line.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'mysql_query("INSERT INTO example'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Again we are using the mysql_query function. "INSERT INTO" means that data is going to be put into a table. The name of the table we specified to insert data into was "example". &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'(name, age) VALUES('Timmy Mellowman', '23' ) ")' &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;"(name, age)" are the two columns we want to add data into. "VALUES" means that what follows is the data to be put into the columns that we just specified. Here we enter the name Timmy Mellowman for "name", and 23 for "age". &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Be sure to note the location and number of apostrophes and parentheses in the PHP code, as this is where a lot of beginner PHP/MySQL programmers run into problems. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Review &amp;amp; Homework&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If all goes as well, this .php page will add a three people to the "example" table every time it is run. Be sure to use your MySQL administration program provided by your web host to ensure that the data was inserted into your table correctly.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Be careful not to run this script more than once, otherwise you will be inserting the same people, multiple times. This is called inserting duplicate records and is usually avoided.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Query&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;So far we have seen a couple different uses of PHP's &lt;i&gt;mysql_query&lt;/i&gt; function and we'll be seeing more of it as nearly all MySQL in PHP is done through the MySQL Query function. We have already created a new table and inserted data into that table. In this lesson we will cover the most common MySQL Query that is used to retrieve information from a database. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!--// &lt;![CDATA[ /* openads=http://tizag.com/oads/www/delivery bannerid=21 zoneid=15 source= */ // ]]&gt; --&gt; &lt;/script&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; //2007-05-21: NContent MySQL google_ad_channel = "9971219636"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "3D81EE"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;script src="http://tizag.com/oads/www/delivery/ag.php" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Retrieving Data With PHP &amp;amp; MySQL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Usually most of the work done with MySQL involves pulling down data from a MySQL database. In MySQL, data is retrieved with the "SELECT" keyword. Think of SELECT as working the same way as it does on your computer. If you wanted to copy some information in a document, you would first select the desired information, then copy and paste. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Using MySQL SELECT &amp;amp; FROM&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Before attempting this lesson, be sure that you have created a table that contains some data, preferably the same data that we had in the &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlinsert.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;MySQL Insert lesson&lt;/span&gt;&lt;/a&gt;. In this example, we will output the first entry of our MySQL "examples" table to the web browser. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_connect("localhost", "admin", "1admin") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_select_db("test") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Retrieve all the data from the "example" table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;$result = mysql_query("SELECT * FROM example")&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// store the record of the "example" table into $row&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$row = mysql_fetch_array( $result );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Print out the contents of the entry &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "Name: ".$row['name'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo " Age: ".$row['age'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Name: Tim Mellowman Age: 23 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This is an example of how to use MySQL's SELECT statement in PHP. Although the MySQL code is simple, printing out the information with PHP is somewhat more involved.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Below is a step-by-step walkthrough of the code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'$result = mysql_query("SELECT * FROM example")'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;When you perform a SELECT query on the database it will return a MySQL Resource that hols everything from your MySQL table, "example". We want to use this Resource in our PHP code, so we need to store it in a variable, &lt;i&gt;$result&lt;/i&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'SELECT * FROM example'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Yes, this is a partial repeat of the same line of code, but we wanted to explain this MySQL statement in greater detail again!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;In English, this line of code reads "Select every entry from the table example". The asterisk is the wild card in MySQL which just tells MySQL to include every single column for that table. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'$row = mysql_fetch_array( $result );'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;i&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;$result&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; is now a MySQL Resource containing data from your MySQL table, "example". Data is being stored in &lt;i&gt;$result&lt;/i&gt;, but it is not yet visible to visitors of your website. When we pass &lt;i&gt;$result&lt;/i&gt; into the &lt;i&gt;mysql_fetch_array&lt;/i&gt; function -- mysql_fetch_array($result) -- an associative array (name, age) is returned.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;In our MySQL table "example," there are only two fields that we care about: name and age. These names are the keys to extracting the data from our associative array. To get the name we use &lt;b&gt;$row['name']&lt;/b&gt; and to get the age we use &lt;b&gt;$row['age']&lt;/b&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;PHP is case sensitive when you reference MySQL column names, so be sure to use capitalization in your PHP code that matches the MySQL column names!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Continuing the Example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;In this lesson, we learned how to get the first entry from a MySQL table and output to the browser using PHP. In the next lesson we will see how to retrieve every entry of a table and put it into a nicely formatted table. However, we recommend that you first understand the PHP and MySQL code in this lesson before proceeding. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Fetch Array&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;MySQL doesn't have a Fetch Array function. &lt;i&gt;mysql_fetch_array&lt;/i&gt; is actually a PHP function that allows you to access data stored in the result returned from a successful &lt;i&gt;mysql_query&lt;/i&gt;. If you have been jumping around our MySQL Tutorial then you would have already seen this function popping up all over the place.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!--// &lt;![CDATA[ /* openads=http://tizag.com/oads/www/delivery bannerid=21 zoneid=15 source= */ // ]]&gt; --&gt; &lt;/script&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; //2007-05-21: NContent MySQL google_ad_channel = "9971219636"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "3D81EE"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;script src="http://tizag.com/oads/www/delivery/ag.php" type="text/javascript"&gt; &lt;/script&gt;This lesson will teach you how and why to use &lt;i&gt;mysql_fetch_array&lt;/i&gt; in your PHP Scripts.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;mysql_fetch_array: Why Use It?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Do you know what is returned when you used the &lt;i&gt;mysql_query&lt;/i&gt; function to query a MySQL database? It isn't something you can directly manipulate, that is for sure. Here is a sample &lt;i&gt;SELECT&lt;/i&gt; query of a table we created in the &lt;a href="http://www.tizag.com/mysqlTutorial/mysqltables.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;MySQL Create Table&lt;/span&gt;&lt;/a&gt; lesson.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP and MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query("SELECT * FROM example");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The value that &lt;i&gt;mysql_query&lt;/i&gt; returns and stores into &lt;i&gt;$result&lt;/i&gt; is a special type of data, it is a MySQL Resource. Additional PHP functions are required to extract the data from this Resource.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;A Row of Data&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The &lt;i&gt;mysql_fetch_array&lt;/i&gt; function takes a MySQL query resource as an argument (&lt;i&gt;$result&lt;/i&gt;) and returns the first row of data returned by the &lt;i&gt;mysql_query&lt;/i&gt;. Our table &lt;i&gt;example&lt;/i&gt; basically looks like the table below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;example MySQL Table:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;age&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Timmy   Mellowman&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;23&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Sandy   Smith&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;21&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Bobby   Wallace&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;15&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The first row of data in this table is "Timmy Mellowman" and "23". When we fetch an array from our MySQL Resource &lt;i&gt;$result&lt;/i&gt; it should have Timmy's name and age in it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Getting a Row of Data using mysql_fetch_array&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;i&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;mysql_fetch_array&lt;/span&gt;&lt;/i&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; returns the first row in a MySQL Resource in the form of an &lt;a href="http://www.tizag.com/phpT/arrays.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;associative array&lt;/span&gt;&lt;/a&gt;. The columns of the MySQL Result can be accessed by using the column names of the table. In our table &lt;i&gt;example&lt;/i&gt; these are: name and age. Here is the code to print out the first MySQL Result row.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP and MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT * FROM example"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$row = mysql_fetch_array($result) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo $row['&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;name&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;']. " - ". $row['&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;age&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Timmy Mellowman - 23 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This is just what we expected would happen! Now, the cool thing about &lt;i&gt;mysql_fetch_array&lt;/i&gt; is that you can use it again on the same MySQL Resource to return the second, third, fourth and so on rows. You can keep doing this until the MySQL Resource has reached the end (which would be three times in our example). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Sounds like an awfully repetitive task. It would be nice if we could get all our results from a MySQL Resource in an easy to do script.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Fetch Array While &lt;st1:place st="on"&gt;Loop&lt;/st1:place&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;As we have said, the &lt;i&gt;mysql_fetch_array&lt;/i&gt; function returns an associative array, but it &lt;b&gt;also&lt;/b&gt; returns FALSE if there are no more rows to return! Using a &lt;a href="http://www.tizag.com/phpT/whileloop.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;PHP While Loop&lt;/span&gt;&lt;/a&gt; we can use this information to our advantage.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If we place the statement "$row = mysql_fetch_array()" as our while loop's conditional statement we will accomplish two things:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;We will get a new row of MySQL information that we can print out each time the while loop checks its conditional statement. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;When there are no more rows the function will return FALSE causing the while loop to stop! &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Now that we know what we need to do and how to go about doing it, the code pretty much writes itself, so let's move on to the next lesson. Just kidding! Here is the code that will print out all the rows of our MySQL Resource.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP and MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT * FROM example"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array($result)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo $row['name']. " - ". $row['age'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Timmy Mellowman - 23&lt;br /&gt;&lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Sandy&lt;/st1:place&gt;&lt;/st1:city&gt; Smith - 21&lt;br /&gt;Bobby Wallace - 15 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;And there we have all the rows from our &lt;i&gt;example&lt;/i&gt; table! You could apply this script to any MySQL table as long as you change both the &lt;i&gt;table name&lt;/i&gt; in the query and the &lt;i&gt;column names&lt;/i&gt; that we have in the associative array.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Select&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;You have seen two types of MySQL queries thus far: the query which we used to create a table and the query we used to insert data into our newly created table. The query in this lesson is SELECT, which is used to &lt;b&gt;get&lt;/b&gt; information from the database, so that its data can be used in our PHP script. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!--// &lt;![CDATA[ /* openads=http://tizag.com/oads/www/delivery bannerid=21 zoneid=15 source= */ // ]]&gt; --&gt; &lt;/script&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; //2007-05-21: NContent MySQL google_ad_channel = "9971219636"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "3D81EE"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;script src="http://tizag.com/oads/www/delivery/ag.php" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Retrieving Information from MySQL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Finally, we get to use the data in our MySQL database to create a dynamic PHP page. In this example we will select everything in our table "example" and put it into a nicely formatted HTML table. Remember, if you don't understand the HTML or PHP code, be sure to check out the &lt;a href="http://www.tizag.com/htmlT/"&gt;&lt;span style="font-size: 8.5pt;"&gt;HTML&lt;/span&gt;&lt;/a&gt; and/or &lt;a href="http://www.tizag.com/phpT/"&gt;&lt;span style="font-size: 8.5pt;"&gt;PHP&lt;/span&gt;&lt;/a&gt; Tutorial(s). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_connect("localhost", "admin", "1admin") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_select_db("test") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Get all the data from the "example" table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query("SELECT * FROM example") &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;or die(mysql_error()); &lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;table border="'1'"&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Age&lt;/th&gt; &lt;/tr&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// keeps getting the next row until there are no more to get&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array( $result )) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;// Print out the contents of each row into a table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;tr&gt;&lt;td&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo $row['name'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;/td&gt;&lt;td&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo $row['age'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;/td&gt;&lt;/tr&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;/table&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Age&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Timmy   Mellowman&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;23&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Sandy   Smith&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;21&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Bobby   Wallace&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;15&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Because we only had three entries in our table, three rows appeared above. If you added more entries to your database's table, then you would see each additional row appear in the above table. If you do not understand the above PHP, you can view our &lt;a href="http://www.tizag.com/phpT/arrays.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;PHP Array Tutorial&lt;/span&gt;&lt;/a&gt; &amp;amp; &lt;a href="http://www.tizag.com/phpT/whileloop.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;PHP Loop Tutorial&lt;/span&gt;&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'$result = mysql_query...'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;When you select items from a database using &lt;i&gt;mysql_query&lt;/i&gt;, the data is returned as a MySQL result. Since we want to use this data in our table we need to store it in a variable. &lt;i&gt;$result&lt;/i&gt; now holds the result from our &lt;i&gt;mysql_query&lt;/i&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'SELECT * FROM example'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;In English, this line of code reads "Select everything from the table example". The asterisk is the wild card in MySQL which just tells MySQL to retrieve &lt;b&gt;every single field&lt;/b&gt; from the table. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;'while($row = mysql_fetch_array( $result )'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The &lt;i&gt;mysql_fetch_array&lt;/i&gt; function gets the next-in-line associative array from a MySQL result. By putting it in a while loop it will continue to fetch the next array until there is no next array to fetch. This function can be called as many times as you want, but it will return FALSE when the last associative array has already been returned.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;By placing this function within the conditional statement of the while loop, we can kill two birds with one stones. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;We can retrieve the next associative array from our MySQL Resource, &lt;i&gt;$result&lt;/i&gt;, so that we can print out the name and age of that person. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;We can tell the while loop to stop printingn out information when the MySQL Resource has returned the last array, as False is returned when it reaches the end and this will cause the while loop to halt. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;In our MySQL table "example" there are only two fields that we care about: name and age. These fields are the keys to extracting the data from our associative array. To get the name we use $row['name'] and to get the age we use $row['age'].&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Practice What You Have Learned&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Use the query that we have provided or make a new one and try putting it into a formatted HTML table. It might be useful to try out other methods of HTML formatting as well. See which one you like best!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;By now you should be starting to understand how powerful PHP and MySQL are when used together. The tasks that you can complete with MySQL and PHP would be nearly impossible to do by hand in HTML. Imagine trying to create an HTML table of 6000 entries without using a MySQL database and a PHP while loop! &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Where&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;In a previous lesson we did a SELECT query to get all the data from our "example" table. If we wanted to select only certain entries of our table, then we would use the keyword WHERE.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!--// &lt;![CDATA[ /* openads=http://tizag.com/oads/www/delivery bannerid=21 zoneid=15 source= */ // ]]&gt; --&gt; &lt;/script&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; //2007-05-21: NContent MySQL google_ad_channel = "9971219636"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "3D81EE"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;script src="http://tizag.com/oads/www/delivery/ag.php" type="text/javascript"&gt; &lt;/script&gt;WHERE lets you specify requirements that entries must meet in order to be returned in the MySQL result. Those entries that do not pass the test will be left out. We will be assuming the data from a &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlinsert.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;previous lesson&lt;/span&gt;&lt;/a&gt; for the following examples.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Being Selective With Your MySQL Selection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;There are three entries in our "example" table: Tim, Sandy, and Bobby. To select &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Sandy&lt;/st1:place&gt;&lt;/st1:city&gt; only we could either specify &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Sandy&lt;/st1:place&gt;&lt;/st1:city&gt;'s age (21) or we could use her name (Sandy Smith). In the future there may be other people who are 21, so we will use her name as our requirement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;WHERE is used in conjuction with a mathematical statement. In our example we will want to select all rows that have the string "Sandy Smith" in the "names" column (mathematically: {name column} = "Sandy Smith"). Here's how to do it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_connect("localhost", "admin", "1admin") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_select_db("test") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Get a specific result from the "example" table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query("SELECT * FROM example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; WHERE name='Sandy Smith'") or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// get the first (and hopefully only) entry from the result&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$row = mysql_fetch_array( $result );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Print out the contents of each row into a table &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo $row['name']." - ".$row['age'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Sandy Smith - 21 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Wildcard Usage '%'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you wanted to select every person in the table who was in their 20's, how could you go about doing it? With the tools you have now, you could make 10 different queries, one for each age 20, 21, 22...but that seems like more work than we need to do.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;In MySQL there is a "wildcard" character '%' that can be used to search for partial matches in your database. The '%' tells MySQL to ignore the text that would normally appear in place of the wildcard. For example '2%' would match the following: 20, 25, 2000000, 2avkldj3jklsaf, and 2! &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;On the other hand, '2%' would not match the following: 122, a20, and 32.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Query WHERE With Wildcard&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;To solve our problem from before, selecting everyone who is their 20's from or MySQL table, we can utilize wildcards to pick out all strings starting with a 2.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Connect to MySQL&lt;br /&gt; &lt;!--[if !supportLineBreakNewLine]--&gt;&lt;br /&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Insert a row of information into the table "example"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query("SELECT * FROM example WHERE age LIKE '2%' ") &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// keeps getting the next row until there are no more to get&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array( $result )) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;// Print out the contents of each row&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo $row['name']." - ".$row['age']. "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Timmy Mellowman - 23&lt;br /&gt;&lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Sandy&lt;/st1:place&gt;&lt;/st1:city&gt; Smith - 21 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;You can use this wildcard at the beginning, middle, and end of the string. Experiment with it so you can see for yourself how powerful this little trick can be.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Note&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;: The wildcard was used for example purposes only. If you really wanted to explicilty select people who are in their 20's you would use greater than 19 and less than 30 to define the 20's range. Using a wildcard in this example would select unwanted cases, like a 2 year old and your 200 year old great-great-great-grandparents.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Order By&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;It would be nice to be able to make MySQL results easier to read and understand. A common way to do this in the real world is to order a big list of items by name or amount. The way to order your result in MySQL is to use the ORDER BY statement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!--// &lt;![CDATA[ /* openads=http://tizag.com/oads/www/delivery bannerid=21 zoneid=15 source= */ // ]]&gt; --&gt; &lt;/script&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; //2007-05-21: NContent MySQL google_ad_channel = "9971219636"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "3D81EE"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;script src="http://tizag.com/oads/www/delivery/ag.php" type="text/javascript"&gt; &lt;/script&gt;What ORDER BY does is take the a column name that you specify and sort it in alphabetical order (or numeric order if you are using numbers). Then when you use &lt;i&gt;mysql_fetch_array&lt;/i&gt; to print out the result, the values are already sorted and easy to read.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Ordering is also used quite frequently to add additional functionality to webpages that use any type of column layout. For example, some forums let you sort by date, thread title, post count, view count, and more.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Sorting a MySQL Query - ORDER BY&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Let's use the same query we had in &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlselect.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;MySQL Select&lt;/span&gt;&lt;/a&gt; and modify it to ORDER BY the person's age. The code from MySQL Select looked like...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_connect("localhost", "admin", "1admin") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_select_db("test") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Get all the data from the "example" table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query("SELECT * FROM example") &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;table border="'1'"&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Age&lt;/th&gt; &lt;/tr&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// keeps getting the next row until there are no more to get&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array( $result )) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;// Print out the contents of each row into a table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;tr&gt;&lt;td&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo $row['name'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;/td&gt;&lt;td&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo $row['age'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;/td&gt;&lt;/tr&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;/table&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Age&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Timmy   Mellowman&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;23&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Sandy   Smith&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;21&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Bobby   Wallace&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;15&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;What we need to do is add on to the existing MySQL statement "SELECT * FROM example" to include our new ordering requirement. When you choose to order a column, be sure that your ORDER BY appears after the SELECT ... FROM part of the MySQL statement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_connect("localhost", "admin", "1admin") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_select_db("test") or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Get all the data from the "example" table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query("SELECT * FROM example &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;ORDER BY age&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;") &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;table border="'1'"&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Age&lt;/th&gt; &lt;/tr&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// keeps getting the next row until there are no more to get&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array( $result )) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;// Print out the contents of each row into a table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;tr&gt;&lt;td&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo $row['name'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;/td&gt;&lt;td&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo $row['age'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;/td&gt;&lt;/tr&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;/table&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Age&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Bobby   Wallace&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;15&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Sandy   Smith&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;21&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Timmy   Mellowman&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;23&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Presto! We have an ordered MySQL result! Notice that we didn't have to change any of our PHP code. Remember this whenever you're editing a PHP script that uses MySQL. Sometimes it may be easier to just tweak your MySQL query instead of trying to mess around in PHP.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Joins&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Thus far we have only been getting data from one table at a time. This is fine for simple takes, but in most real world MySQL usage you will often need to get data from multiple tables in a single query.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The act of &lt;i&gt;joining&lt;/i&gt; in MySQL refers to smashing two or more tables into a &lt;b&gt;single&lt;/b&gt; table. This means everything you have learned so far can be applied after you've created this new, &lt;i&gt;joined&lt;/i&gt; table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Join Table Setup&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;We like to show examples and code before we explain anything in detail, so here is how you would combine two tables into one using MySQL. The two tables we will be using relate to a families eating habits.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;family Table:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Position&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Age&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Dad&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;41&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Mom&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;45&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Daughter&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;17&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Dog&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;food Table:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Meal&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Position&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Steak&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Dad&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Salad&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Mom&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Spinach   Soup&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Tacos&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Dad&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The important thing to note here is that the column &lt;i&gt;Position&lt;/i&gt; contains information that can tie these two tables together. In the "family" table, the &lt;i&gt;Position&lt;/i&gt; column contains all the members of the family and their respective ages. In the "food" table the &lt;i&gt;Position&lt;/i&gt; column contains the family member who enjoys that dish.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;It's only through a shared column relationship such as this that tables can be &lt;i&gt;joined&lt;/i&gt; together, so remember this when creating tables you wish to have interact with each other.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Join Simple Example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Let's imagine that we wanted to SELECT all the dishes that were liked by a family member. If you remember from the previous lesson, this is a situation when we need to use the &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlwhere.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;WHERE&lt;/span&gt;&lt;/a&gt; clause. We want to SELECT all the dishes WHERE a family member likes it. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;We will be performing a generic &lt;i&gt;join&lt;/i&gt; of these two tables using the &lt;i&gt;Position&lt;/i&gt; column from each table as the connector. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Note&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;: This example assumes you have created the MySQL tables "food" and "family". If you do not have either of them created, you can either create them using our &lt;a href="http://www.tizag.com/mysqlTutorial/mysqltables.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;MySQL Create Table&lt;/span&gt;&lt;/a&gt; lesson or do it manually yourself.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP and MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Construct our join query&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;family.Position, food.Meal&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; ".&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; "FROM family, food ".&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;"WHERE &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;family.Position = food.Position&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Print out the contents of each row into a table &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array($result)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo $row['Position']. " - ". $row['Meal'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The statement "WHERE family.Position = food.Position" will restrict the results to the rows where the &lt;i&gt;Position&lt;/i&gt; exists in &lt;b&gt;both&lt;/b&gt; the "family" and "food" tables. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Dad - Steak&lt;br /&gt;Mom - Salad&lt;br /&gt;Dad - Tacos &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Those are the results of our PHP script. Let's analyze the tables to make sure we agree with these results.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Compare the Tables:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Position&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Age&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: red;"&gt;Dad&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;41&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: red;"&gt;Mom&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;45&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Daughter&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;17&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Dog&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black; display: none;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Meal&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Position&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Steak&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: red;"&gt;Dad&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Salad&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: red;"&gt;Mom&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Spinach   Soup&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Tacos&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: red;"&gt;Dad&lt;/span&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Our results show that there were three meals that were liked by family members. And by manually perusing the tables it looks like there were indeed three meals liked by family members.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Note&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;: This is a very simple example of a join. If you do not understand it yet do not despair. Joins are a very hard concept to grasp for beginning MySQL developers.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL LEFT JOIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;In the previous lesson, &lt;a href="http://www.tizag.com/mysqlTutorial/mysqljoins.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Mysql Joins&lt;/span&gt;&lt;/a&gt; we learned how to do a basic join of two tables. This lesson will teach you how to do a specialized join: &lt;i&gt;left join&lt;/i&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL LEFT JOIN Explanation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;How is a LEFT JOIN different from a normal join? First of all, the syntax is quite different and somewhat more complex. Besides looking different, the LEFT JOIN gives extra consideration to the table that is on the left.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Being "on the left" simply refers to the table that appears before the LEFT JOIN in our SQL statement. Nothing tricky about that. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This extra consideration to the left table can be thought of as special kind of preservation. Each item in the left table will show up in a MySQL result, &lt;b&gt;even&lt;/b&gt; if there isn't a match with the other table that it is being joined to.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Join and LEFT JOIN Differences&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Here are the tables we used in the previous &lt;a href="http://www.tizag.com/mysqlTutorial/mysqljoins.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Mysql Joins&lt;/span&gt;&lt;/a&gt; lesson.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;MySQL family and food Tables:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Position&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Age&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Dad&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;41&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Mom&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;45&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Daughter&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;17&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Dog&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black; display: none;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Meal&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Position&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Steak&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Dad&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Salad&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Mom&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Spinach   Soup&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Tacos&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Dad&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;We executed a simple query that selected all meals that were liked by a family member with this simple join query:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Simplified MySQL Query:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;SELECT food.Meal, family.Position &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;FROM family, food&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;WHERE food.Position = family.Position&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Result:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Dad - Steak&lt;br /&gt;Mom - Salad&lt;br /&gt;Dad - Tacos &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;When we decide to use a LEFT JOIN in the query instead, all the family members be listed, even if they do not have a favorite dish in our &lt;i&gt;food&lt;/i&gt; table. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This is because a left join will preserve the records of the "left" table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL LEFT JOIN Example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The code below is the exact same as the code in the previous lesson, except the LEFT JOIN has now been added to the query. Let's see if the results are what we expected.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP and MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Construct our join query&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT family.Position, food.Meal ".&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; "FROM family &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;LEFT JOIN&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; food ".&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;"&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;ON&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; family.Position = food.Position"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Print out the contents of each row into a table &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array($result)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo $row['Position']. " - ". $row['Meal'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Dad - Steak&lt;br /&gt;Dad - Tacos&lt;br /&gt;Mom - Salad&lt;br /&gt;Daughter -&lt;br /&gt;Dog - &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Success! The LEFT JOIN preserved every family member, including those who don't yet have a favorite meal in the &lt;i&gt;food&lt;/i&gt; table! Please feel free to play around with LEFT JOIN until you feel like you have a solid grasp of it. This stuff isn't easy!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Update&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Imagine that you have a MySQL table that holds the information of all the employees in your company. One of the columns in this table is called "Seniority" and it holds an integer value of how many months an employee has worked at your company. Unfortunately for you, your job is to update these numbers every month.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;You may be thinking that you'll have to open up your MySQL administration tool and edit each entry by hand. That would take hours. On the other hand, you could master MySQL and have an automated script that you run each month to get the job done for you. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;In this lesson you will learn how to replace the existing data of a MySQL table with freshly supplied up-to-date data using the UPDATE MySQL query. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Update Example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Once again we will be working with the data from a &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlinsert.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;previous example&lt;/span&gt;&lt;/a&gt;. &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Sandy&lt;/st1:place&gt;&lt;/st1:city&gt; has just had a birthday and she now 22 years old. Our job now is to update her age using MySQL commands like UPDATE, SET, and WHERE. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;UPDATE&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - Performs an update MySQL query &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;SET&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - The new values to be placed into the table follow SET &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;WHERE&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - Limits which rows are affected &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Connect to MySQL&lt;br /&gt; &lt;!--[if !supportLineBreakNewLine]--&gt;&lt;br /&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Get &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Sandy&lt;/st1:place&gt;&lt;/st1:city&gt;'s record from the "example" table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query("UPDATE example SET age='22' WHERE age='21'") &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query("SELECT * FROM example WHERE age='22'") &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// get the first (and hopefully only) entry from the result&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$row = mysql_fetch_array( $result );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo $row['name']." - ".$row['age']. "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Sandy Smith - 22 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Now it is important to note that this query would have updated ALL records that had an age of 21 to the new age of 22. In a table where &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Sandy&lt;/st1:place&gt;&lt;/st1:city&gt; is not the onlyl entry, this may become a problem, and a more sophisticated solution would be necessary.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Delete&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Maintenance is a very common task that is necessary for keeping MySQL tables current. From time to time, you may even need to delete items from your database. Some potential reasons for deleting a record from MySQL include when: someone deletes a post from a forum, an employee leaves a company, or you're trying to destroy your records before the federalies come! &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL DELETE Example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The DELETE query is very similar to the &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlupdate.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;UPDATE Query in the previous lesson&lt;/span&gt;&lt;/a&gt;. We need to choose a table, tell MySQL to perform the deletion, and provide the requirements that a record must have for it to be deleted. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Say we want to delete the youngest employee from our &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlinsert.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;previously created table&lt;/span&gt;&lt;/a&gt; because he has to go back to school. This is how we do it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Connect to MySQL&lt;br /&gt; &lt;!--[if !supportLineBreakNewLine]--&gt;&lt;br /&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Delete Bobby from the "example" MySQL table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query("DELETE FROM example WHERE age='15'") &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;or die(mysql_error());&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;It is important to note that this query would have deleted ALL records that had an age of 15. Since Bobby was the only 15 year old this was not a problem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL DELETE Tips&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Before performing a large delete on a database, be sure to back up the table/database in case your script takes off a little more than desired. Test your delete queries before even thinking about using them on your table. As long as you take caution when using this powerful query you should not run into any problems.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Database Backups&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you're storing anything in MySQL databases that you do not want to lose, chances are you should be doing weekly or even daily backups. Depending on what you're using your databases for -- be it to store forum messages, employee information, or your spending information -- you are going to need to choose a backup schedule that meets your needs. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;You may or may not know that MySQL databases are just files that are stored on your web server. This fact makes the whole backup and restore process extremely simple and painless once you have figured out how to do it. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Different Ways to Get That Backup Done&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;There are many paths you can take to create a MySQL backup. However, no matter which application, control panel tool, or SSH script you use, all of the backups will fit into two types of backups: a dump or raw backup. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Dump&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;A MySQL dump is a bit slower than a raw backup because it creates all the SQL queries required to create the tables of that database, as well as all the insert queries required to place the information back into the database's tables.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you want to perform the mysql dump manually, without the assistance of your hosts control panel, then run SSH to your web server and do the following (taken from &lt;a href="http://dev.mysql.com/doc/refman/5.0/en/backup.html"&gt;&lt;span style="font-size: 8.5pt;"&gt;MySql.com&lt;/span&gt;&lt;/a&gt;): &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;mysqldump --tab=/path/to/some/dir --opt db_name &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you were to open up a MySQL dump file you would see a slew of SQL queries that you would probably be able to understand (if you've already read through this whole tutorial!). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Raw Backup&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;A MySQL Raw Backup is quicker because it does not translate the contents of the database into human readable SQL queries. However, not many control panels support this type of backup, so do not worry if your hosting provider doesn't have this option set up for you.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Backup in Control Panel cPanel&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;a href="http://www.cpanel.net/"&gt;&lt;span style="font-size: 8.5pt;"&gt;cPanel&lt;/span&gt;&lt;/a&gt; is the most widely used web host control panel at this time, so we thought it would make sense to provide a walkthrough specifically for cPanel.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;From the application selection screen click "Backup". This will bring you to the backup application that allows you to generate and download complete backups for your site. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;To back up a database individually, look for the title "Download a SQL Database Backup" or something similar. Below that title should be a listing of every database that you have created. Simply click on the name of the database you want to backup and save it to your computer.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;That's it! Now just be sure that you have a regular backup schedule, just in case the unthinkable happens and your web host loses all your database information!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL GROUP BY - Aggregate Functions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;After you have mastered the basics of MySQL, it's time to take the next step and take on Aggregate Functions. Before we talk about what they are, let's review the definition of aggregate, as it relates to MySQL:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Aggregate&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; - Constituting or amounting to a whole; total. ~American Heritage Dictionary &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;With this type of wording, we can assume that MySQL's aggregate functions are something that will be very top-level, or in other words, the opposite of detailed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The most common types of aggregate functions let you find out things like the minimum, maximum and even the average of a "grouped" set of data. The trick to understanding aggregate functions is often understanding what kind of data is being grouped and analyzed. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL GROUP BY - The Data&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Before we can start throwing around these fancy functions, let's build an appropriate table that has enough data in it to be meaningful to us. Below is the SQL for our "products" table. You can either run this SQL statement in your MySQL administrator software or use MySQL to execute the queries (i.e. create table, then each of the records).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;You can download the &lt;a href="http://www.tizag.com/files/mysql/products.sql"&gt;&lt;span style="font-size: 8.5pt;"&gt;products.sql&lt;/span&gt;&lt;/a&gt; file from our website. If you are new to MySQL you will need to know how to &lt;a href="http://www.tizag.com/mysqlTutorial/mysqltables.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Create a MySQL Table&lt;/span&gt;&lt;/a&gt; and &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlinsert.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Insert a MySQL Row&lt;/span&gt;&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Below is the MySQL table &lt;i&gt;products&lt;/i&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Products Table:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;type&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;price&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123451&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Park's   Great Hits&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;19.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123452&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Silly   Puddy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123453&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Playstation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;89.95&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123454&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Men's   T-Shirt&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;32.50&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123455&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Blouse&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;34.97&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123456&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Electronica   2002&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123457&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Country   Tunes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;21.55&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123458&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Watermelon&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Food&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;8.73&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;GROUP BY - Creating Your First "Group" &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Imagine that our store was running an advertisement in the newspaper and we wanted to have a "bargain basement" section that listed the lowest price of each product type. In this case we would be "grouping" by the product type and finding the minimum price of each group.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Our query needs to return two columns: product type and minimum price. Additionally, we want to use the &lt;i&gt;type&lt;/i&gt; column as our group. The SELECT statement we are about to use will look different because it includes an aggregate function, MIN, and the GROUP BY statement, but otherwise it isn't any different than a normal SELECT statement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP and MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT type, &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;MIN(price)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; FROM products &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;GROUP BY type&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Print out result&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array($result)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo $row['type']. " - $". $row['&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;MIN(price)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Our "products" table has four types of products: Music, Toy, Clothing and Food. When we GROUP BY &lt;i&gt;type&lt;/i&gt; then we get one result for each of these types.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Clothing - $32.50&lt;br /&gt;Food - $8.73&lt;br /&gt;Music - $3.99&lt;br /&gt;Toy - $3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL GROUP BY - Review&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Group BY is good for retrieving information about a group of data. If you only had one product of each type, then GROUP BY would not be all that useful.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;GROUP BY only shines when you have many similar things. For example, if you have a number of products of the same type, and you want to find out some statistical information like the minimum, maximum, or other top-level info, you would use GROUP BY.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Some technical rules of GROUP BY:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The column that you GROUP BY must also be in your SELECT statement. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Remember to group by the column you want information about and not the one you are applying the aggregate function on. In our above example we wanted information on the &lt;i&gt;type&lt;/i&gt; column and the aggregate function was applied to the &lt;i&gt;price&lt;/i&gt; column. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The next few lessons will provide a walkthrough for using other popular MySQL aggregate functions in conjunction with the &lt;i&gt;GROUP BY&lt;/i&gt; statement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Aggregate Functions - COUNT()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This lesson will teach you how to use the aggregate function COUNT(). If you missed the &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlgroupby.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Aggregate Introduction Lesson&lt;/span&gt;&lt;/a&gt;, please check it out now, as it explains many concepts used in this lesson!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;We will be using the "products" table that we constructed to display the use of MySQL's COUNT function.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;You can download the &lt;a href="http://www.tizag.com/files/mysql/products.sql"&gt;&lt;span style="font-size: 8.5pt;"&gt;products.sql&lt;/span&gt;&lt;/a&gt; file from our website. If you are new to MySQL you will need to know how to &lt;a href="http://www.tizag.com/mysqlTutorial/mysqltables.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Create a MySQL Table&lt;/span&gt;&lt;/a&gt; and &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlinsert.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Insert a MySQL Row&lt;/span&gt;&lt;/a&gt; first.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Below is the MySQL table "products".&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Products Table:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;type&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;price&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123451&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Park's   Great Hits&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;19.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123452&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Silly   Puddy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123453&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Playstation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;89.95&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123454&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Men's   T-Shirt&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;32.50&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123455&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Blouse&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;34.97&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123456&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Electronica   2002&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123457&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Country   Tunes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;21.55&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123458&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Watermelon&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Food&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;8.73&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL COUNT - Counting Records&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The COUNT function is an aggregate function that simply counts all the items that are in a group. The "products" table that is displayed above has several products of various types. One use of COUNT might be to find out how many items of each type there are in the table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Just as we did in the aggregate introduction lesson, we are going to GROUP BY &lt;i&gt;type&lt;/i&gt; to create four groups: Music, Toy, Clothing and Food. For a slight change of pace, let's count the &lt;i&gt;name&lt;/i&gt; column to find how many products there are per type.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP and MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT type, &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;COUNT(name)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; FROM products &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;GROUP BY type&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Print out result&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array($result)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "There are ". $row['&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;COUNT(name)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;'] ." ". $row['type'] ." items.";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;There are 2 Clothing items.&lt;br /&gt;There are 1 Food items.&lt;br /&gt;There are 3 Music items.&lt;br /&gt;There are 2 Toy items. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Aggregate Functions - SUM()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This lesson will teach you how to use the aggregate function SUM(). If you haven't already read through Tizag's &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlgroupby.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Aggregate Introduction Lesson&lt;/span&gt;&lt;/a&gt;, please check it out now. It explains concepts used in this lesson.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!--// &lt;![CDATA[ /* openads=http://tizag.com/oads/www/delivery bannerid=21 zoneid=15 source= */ // ]]&gt; --&gt; &lt;/script&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; //2007-05-21: NContent MySQL google_ad_channel = "9971219636"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "3D81EE"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;script src="http://tizag.com/oads/www/delivery/ag.php" type="text/javascript"&gt; &lt;/script&gt;We will be using the "products" table again -- this time to display the use of MySQL's SUM function.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;You can download the &lt;a href="http://www.tizag.com/files/mysql/products.sql"&gt;&lt;span style="font-size: 8.5pt;"&gt;products.sql&lt;/span&gt;&lt;/a&gt; file from our website. If you are new to MySQL you will need to know how to &lt;a href="http://www.tizag.com/mysqlTutorial/mysqltables.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Create a MySQL Table&lt;/span&gt;&lt;/a&gt; and &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlinsert.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Insert a MySQL Row&lt;/span&gt;&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Here's a visual of the "products" table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Products Table:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;type&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;price&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123451&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Park's   Great Hits&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;19.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123452&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Silly   Puddy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123453&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Playstation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;89.95&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123454&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Men's   T-Shirt&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;32.50&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123455&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Blouse&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;34.97&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123456&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Electronica   2002&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123457&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Country   Tunes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;21.55&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123458&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Watermelon&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Food&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;8.73&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL SUM - Totaling Groups&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;SUM is an aggregate function that totals a specific column for a group. The "products" table that is displayed above has several products of various types. One use of SUM might be to find the total of all the items' &lt;i&gt;price&lt;/i&gt; for each product &lt;i&gt;type&lt;/i&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Just as we did in the aggregate introduction lesson, we are going to apply the aggregate function to &lt;i&gt;price&lt;/i&gt; and GROUP BY &lt;i&gt;type&lt;/i&gt; to create four groups: Music, Toy, Clothing and Food.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP and MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT type, &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;SUM(price)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; FROM products &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;GROUP BY type&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Print out result&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array($result)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "Total ". $row['type']. " = $". $row['&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;SUM(price)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Total Clothing = $67.47&lt;br /&gt;Total Food = $8.73&lt;br /&gt;Total Music = $45.53&lt;br /&gt;Total Toy = $93.94 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Aggregate Functions - AVG()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This lesson will teach you how to use the aggregate function AVG(). If you missed the &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlgroupby.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Aggregate Introduction Lesson&lt;/span&gt;&lt;/a&gt;, please check it out now. It explains the meaning of aggregates and describes the GROUP BY statement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The table we will be using is "products" and you can download the &lt;a href="http://www.tizag.com/files/mysql/products.sql"&gt;&lt;span style="font-size: 8.5pt;"&gt;products.sql&lt;/span&gt;&lt;/a&gt; file so you can follow along. The table can be entered through you MySQL interface or through PHP.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you are new to MySQL/PHP programming you will need to know how to &lt;a href="http://www.tizag.com/mysqlTutorial/mysqltables.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Create a MySQL Table&lt;/span&gt;&lt;/a&gt; and &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlinsert.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Insert a MySQL Row&lt;/span&gt;&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Products Table:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;type&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;price&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123451&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Park's   Great Hits&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;19.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123452&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Silly   Puddy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123453&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Playstation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;89.95&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123454&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Men's   T-Shirt&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;32.50&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123455&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Blouse&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;34.97&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123456&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Electronica   2002&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123457&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Country   Tunes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;21.55&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123458&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Watermelon&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Food&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;8.73&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Average - Finding a Middle Ground&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The AVG function returns the average value for the specified column of a group. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Our imaginary customers have been complaining recently that our prices are too high, so we would like to find out the average &lt;i&gt;price&lt;/i&gt; of each product &lt;i&gt;type&lt;/i&gt; to see if this is in fact the truth.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;To find out this metric we are going to apply the aggregate function to the &lt;i&gt;price&lt;/i&gt; and GROUP BY &lt;i&gt;type&lt;/i&gt; to create four price groups: Music, Toy, Clothing and Food.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP and MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT type, &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;AVG(price)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; FROM products &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;GROUP BY type&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Print out result&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array($result)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "The average price of ". $row['type']. " is $".$row['&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;AVG(price)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;The average price of Clothing is $33.735000&lt;br /&gt;The average price of Food is $8.730000&lt;br /&gt;The average price of Music is $15.176667&lt;br /&gt;The average price of Toy is $46.970000 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Those prices seem very reasonable, in my opinion. I think our imaginary customers should change their view and keep buying products from us.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Aggregate Functions - MIN()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This lesson will teach you how to use the aggregate function MIN(). If you missed the &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlgroupby.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Aggregate Introduction Lesson&lt;/span&gt;&lt;/a&gt;, you might want to check it out to learn about the GROUP BY statement and its use with MySQL aggregate functions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;You can download the table used in this example, &lt;a href="http://www.tizag.com/files/mysql/products.sql"&gt;&lt;span style="font-size: 8.5pt;"&gt;products.sql&lt;/span&gt;&lt;/a&gt;, from our website. A SQL file can be run through your MySQL administrator interface to create the table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;However, if you would like to create the table with PHP/MySQL, check out our &lt;a href="http://www.tizag.com/mysqlTutorial/mysqltables.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Create a MySQL Table&lt;/span&gt;&lt;/a&gt; and &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlinsert.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Insert a MySQL Row&lt;/span&gt;&lt;/a&gt; lessons.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Products Table:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;type&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;price&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123451&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Park's   Great Hits&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;19.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123452&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Silly   Puddy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123453&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Playstation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;89.95&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123454&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Men's   T-Shirt&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;32.50&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123455&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Blouse&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;34.97&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123456&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Electronica   2002&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123457&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Country   Tunes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;21.55&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123458&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Watermelon&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Food&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;8.73&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL MIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The MIN function is an aggregate function that finds the smallest value in a group. The products table that is displayed above has several products of various types. One use of MIN might be to find out the cheapest item in each group.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Just as we did in the &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlgroupby.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Aggregate Introduction Lesson&lt;/span&gt;&lt;/a&gt;, we are going to GROUP BY &lt;i&gt;type&lt;/i&gt; to create four groups: Music, Toy, Clothing and Food. The column that will have the MIN function applied to it is, of course, &lt;i&gt;price&lt;/i&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP and MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT type, &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;MIN(price)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; FROM products &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;GROUP BY type&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Print out result&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array($result)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "The cheapest&lt;span style=""&gt;  &lt;/span&gt;". $row['type']. " is $" .$row['&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;MIN(price)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;The cheapest Clothing is $32.50&lt;br /&gt;The cheapest Food is $8.73&lt;br /&gt;The cheapest Music is $3.99&lt;br /&gt;The cheapest Toy is $3.99 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Aggregate Functions - MAX()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This lesson will teach you how to use the MAX() aggregate function . If you missed the &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlgroupby.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Aggregate Introduction Lesson&lt;/span&gt;&lt;/a&gt;, please check it out now, as it explains many concepts used in this lesson!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;You can download the example the &lt;a href="http://www.tizag.com/files/mysql/products.sql"&gt;&lt;span style="font-size: 8.5pt;"&gt;products.sql&lt;/span&gt;&lt;/a&gt; file from our website, which contains the SQL for the table below. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you would like to use PHP/MySQL to create the table, then you will need to know how to &lt;a href="http://www.tizag.com/mysqlTutorial/mysqltables.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Create a MySQL Table&lt;/span&gt;&lt;/a&gt; and &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlinsert.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;Insert a MySQL Row&lt;/span&gt;&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Below is the MySQL table "products".&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Products Table:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;type&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;price&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123451&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Park's   Great Hits&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;19.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123452&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Silly   Puddy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123453&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Playstation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Toy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;89.95&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123454&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Men's   T-Shirt&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;32.50&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123455&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Blouse&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Clothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;34.97&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123456&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Electronica   2002&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;3.99&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123457&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Country   Tunes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Music&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;21.55&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;123458&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Watermelon&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;Food&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;8.73&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL MAX - Finding the Big One&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;MySQL's MAX aggregate function will find the largest value in a group. The "products" table that is displayed above has several products of various types. We could use the MAX function to find the most expensive item for each &lt;i&gt;type&lt;/i&gt; of product.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Just as we did in the aggregate introduction lesson, we are going to GROUP BY &lt;i&gt;type&lt;/i&gt; to create four groups: Music, Toy, Clothing and Food. We will also be applying the aggregate function to the &lt;i&gt;price&lt;/i&gt; column.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP and MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Make a MySQL Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT type, &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;MAX(price)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt; FROM products &lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;GROUP BY type&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// Print out result&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array($result)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "The most expensive&lt;span style=""&gt;  &lt;/span&gt;". $row['type']. " is $" .$row['&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;MAX(price)&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;'];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;The most expensive Clothing is $34.97&lt;br /&gt;The most expensive Food is $8.73&lt;br /&gt;The most expensive Music is $21.55&lt;br /&gt;The most expensive Toy is $89.95 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL - SQL Injection Prevention&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you have ever taken raw user input and inserted it into a MySQL database there's a chance that you have left yourself wide open for a security issue known as &lt;i&gt;SQL Injection&lt;/i&gt;. This lesson will teach you how to help prevent this from happening and help you secure your scripts and MySQL statements.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!--// &lt;![CDATA[ /* openads=http://tizag.com/oads/www/delivery bannerid=21 zoneid=15 source= */ // ]]&gt; --&gt; &lt;/script&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; //2007-05-21: NContent MySQL google_ad_channel = "9971219636"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "3D81EE"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;script src="http://tizag.com/oads/www/delivery/ag.php" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;What is SQL Injection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;SQL injection refers to the act of someone inserting a MySQL statement to be run on your database without your knowledge. Injection usually occurs when you ask a user for input, like their name, and instead of a name they give you a MySQL statement that you will unknowingly run on your database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;SQL Injection Example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Below is a sample string that has been gathered from a normal user and a bad user trying to use SQL Injection. We asked the users for their login, which will be used to run a SELECT statement to get their information.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;MySQL &amp;amp; PHP Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// a good user's name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$name = "timmy"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT * FROM customers WHERE username = '$name'";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Normal&lt;/st1:place&gt;&lt;/st1:city&gt;: " . $query . "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// user input that uses SQL Injection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;$name_bad = "' OR 1'"&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// our MySQL query builder, however, not a very safe one&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_bad = "SELECT * FROM customers WHERE username = '$name_bad'";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// display what the new query will look like, with injection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "Injection: " . $query_bad;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Normal: SELECT * FROM customers WHERE username = 'timmy'&lt;br /&gt;Injection: SELECT * FROM customers WHERE username = '' OR 1'' &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The normal query is no problem, as our MySQL statement will just select everything from customers that has a username equal to &lt;i&gt;timmy&lt;/i&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;However&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;, the injection attack has actually made our query behave differently than we intended. By using a single quote (') they have ended the string part of our MySQL query&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;username = ' ' &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;and then added on to our WHERE statement with an OR clause of 1 (always true). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;username = ' ' &lt;b&gt;OR 1 &lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;This OR clause of 1 will always be &lt;i&gt;true&lt;/i&gt; and so &lt;b&gt;every single entry&lt;/b&gt; in the "customers" table would be selected by this statement!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;More Serious SQL Injection Attacks&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Although the above example displayed a situation where an attacker could possibly get access to a lot of information they shouldn't have, the attacks can be a lot worse. For example an attacker could empty out a table by executing a &lt;i&gt;DELETE&lt;/i&gt; statement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;MySQL &amp;amp; PHP Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;$name_evil = "'; DELETE FROM customers WHERE 1 or username = '"&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// our MySQL query builder really should check for injection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_evil = "SELECT * FROM customers WHERE username = '$name_evil'";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// the new evil injection query would include a DELETE statement&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "Injection: " . $query_evil;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;SELECT * FROM customers WHERE username = ' '; DELETE FROM customers WHERE 1 or username = ' ' &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you were run this query, then the injected DELETE statement would completely empty your "customers" table. Now that you know this is a problem, how can you prevent it?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Injection Prevention - mysql_real_escape_string()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Lucky for you, this problem has been known for a while and PHP has a specially-made function to prevent these attacks. All you need to do is use the mouthful of a function &lt;i&gt;mysql_real_escape_string&lt;/i&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;What &lt;i&gt;mysql_real_escape_string&lt;/i&gt; does is take a string that is going to be used in a MySQL query and return the same string with all SQL Injection attempts safely escaped. Basically, it will replace those troublesome quotes(') a user might enter with a MySQL-safe substitute, an escaped quote \'.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Lets try out this function on our two previous injection attacks and see how it works.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;MySQL &amp;amp; PHP Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;//NOTE: you must be connected to the database to use this function!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;// connect to MySQL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$name_bad = "' OR 1'"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;$name_bad = mysql_real_escape_string($name_bad);&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_bad = "SELECT * FROM customers WHERE username = '$name_bad'";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "Escaped Bad Injection: &lt;br /&gt;" . $query_bad . "&lt;br /&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$name_evil = "'; DELETE FROM customers WHERE 1 or username = '"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;$name_evil = mysql_real_escape_string($name_evil);&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_evil = "SELECT * FROM customers WHERE username = '$name_evil'";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "Escaped Evil Injection: &lt;br /&gt;" . $query_evil;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p class="MsoNormal" style="background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 9.5pt; font-family: Verdana; color: black;"&gt;Escaped Bad Injection:&lt;br /&gt;SELECT * FROM customers WHERE username = '\' OR 1\''&lt;br /&gt;Escaped Evil Injection:&lt;br /&gt;SELECT * FROM customers WHERE username = '\'; DELETE FROM customers WHERE 1 or username = \'' &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Notice that those evil quotes have been escaped with a backslash \, preventing the injection attack. Now all these queries will do is try to find a username that is just completely ridiculous:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Bad: \' OR 1\' &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Evil: \'; DELETE FROM customers WHERE 1 or username = \' &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;And I don't think we have to worry about those silly usernames getting access to our MySQL database. So please do use the handy &lt;i&gt;mysql_real_escape_string()&lt;/i&gt; function to help prevent SQL Injection attacks on your websites. You have no excuse not to use it after reading this lesson!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Date - Formats&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;MySQL comes with several data types for storing a date in its database system: DATETIME, DATE, TIMESTAMP, and YEAR. This lesson will show you the proper formats of each type, show their related MySQL functions, and give an &lt;a href="http://www.tizag.com/mysqlTutorial/mysqlinsert.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;INSERT example&lt;/span&gt;&lt;/a&gt; of each.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;These date types are chosen for a column when you &lt;a href="http://www.tizag.com/mysqlTutorial/mysqltables.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;create a new table in MySQL&lt;/span&gt;&lt;/a&gt;. Often the most difficult part of using dates in MySQL is to be sure the format of the date you are trying to store matches the format of your table's date column. If you haven't already, try to create a new MySQL table with the date types we mentioned above.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;We have assembled a "date playground" MySQL table that can be used to follow along with this lesson. &lt;a href="http://www.tizag.com/mysqlTutorial/dateplayground.sql"&gt;&lt;span style="font-size: 8.5pt;"&gt;dateplayground.sql&lt;/span&gt;&lt;/a&gt;. Also, the following acronyms are used in this lesson:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Y - year segment &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;M - month segment &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;D - day segment &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;H - hour segment &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;m - minute segment, note the lower case &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;S - sec segment &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Date - DATE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The default way to store a date in MySQL is with the type DATE. Below is the proper format of a DATE.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;YYYY-MM-DD&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;st1:place st="on"&gt;&lt;st1:placename st="on"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Date&lt;/span&gt;&lt;/b&gt;&lt;/st1:placename&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; &lt;st1:placetype st="on"&gt;Range&lt;/st1:placetype&gt;&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;: 1000-01-01 to 9999-12-31 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you try to enter a date in a format other than the Year-Month-Day format then it might work, but it won't be storing them as you expect.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;To insert the current date into your table you can use MySQL's built-in function CURDATE() in your query. Below we have created 2 dates, one manually and one using CURDATE().&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;//This assumes you have already created the 'dateplayground' table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;//Connect to DB&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_manual = "INSERT INTO dateplayground (dp_name, dp_date)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUES ('DATE: Manual Date', '2020-2-14')";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_auto = "INSERT INTO dateplayground (dp_name, dp_date)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUE ('DATE: Auto CURDATE()', CURDATE() )";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_manual) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_auto) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Date - YEAR&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you just need to store the year of an event, MySQL also has a date type just for that. YEAR's format is simply:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;YYYY&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;st1:place st="on"&gt;&lt;st1:placename st="on"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Date&lt;/span&gt;&lt;/b&gt;&lt;/st1:placename&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; &lt;st1:placetype st="on"&gt;Range&lt;/st1:placetype&gt;&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;: 1901 to 2155 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;It should be noted that the range of years that can be stored are from 1901 to 2155. If you need to store years outside that range then use DATE instead of YEAR.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Below we have created another manual and automatic example to show off YEAR's use. We have used CURDATE() again, even though it provides a lot more information than YEAR requires. All the date information, besides the year, is just ignored by YEAR. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_manual = "INSERT INTO dateplayground (dp_name, dp_year)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUES ('YEAR: Manual Year', '2011')";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_auto = "INSERT INTO dateplayground (dp_name, dp_year)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUE ('YEAR: Auto CURDATE()', CURDATE() )";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_manual) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_auto) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Date - DATETIME&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;DATETIME actually stores both the current date and time, meaning it has the ability to store the year, month, day, hour, minute, and second inside it. DATETIME's format is:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;YYYY-MM-DD HH:mm:SS&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;st1:place st="on"&gt;&lt;st1:placename st="on"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Date&lt;/span&gt;&lt;/b&gt;&lt;/st1:placename&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; &lt;st1:placetype st="on"&gt;Range&lt;/st1:placetype&gt;&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;: 1000-01-01 &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt; to 9999-12-31 &lt;st1:time minute="59" hour="23" st="on"&gt;23:59:59&lt;/st1:time&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The hyphen and the colon are the standard character to separate a date and time respectively, but MySQL allows for you to choose your own delimiters if you wish.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;With DATETIME you can choose to store the date or the time and date together, &lt;b&gt;but&lt;/b&gt; you cannot store just the time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;In our example below we have manually stored a complete DATETIME and also used three different MySQL functions: CURDATE(), CURTIME(), and NOW().&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_manual = "INSERT INTO dateplayground (dp_name, dp_datetime)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUES ('DATETIME: Manual DateTime', '1776-7-4 &lt;st1:time minute="13" hour="16" st="on"&gt;04:13:54&lt;/st1:time&gt;')";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_autodate = "INSERT INTO dateplayground (dp_name, dp_datetime)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUE ('DATETIME: Auto CURDATE()', CURDATE() )";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_autotime = "INSERT INTO dateplayground (dp_name, dp_datetime)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUE ('DATETIME: Auto CURTIME()', CURTIME() )";&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;//This will fail&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_autonow = "INSERT INTO dateplayground (dp_name, dp_datetime)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUE ('DATETIME: Auto NOW()', NOW() )";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_manual) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_autodate) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_autotime) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_autonow) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Date - TIMESTAMP&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;TIMESTAMP is a format popularized by the *NIX operating systems that stores the amount of time that has passed since &lt;st1:date year="1970" day="1" month="1" st="on"&gt;January  1, 1970&lt;/st1:date&gt;. If you want more versatility than this date type provides, remember to try DATETIME.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;YYYY-MM-DD HH:mm:SS&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;st1:place st="on"&gt;&lt;st1:placename st="on"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Date&lt;/span&gt;&lt;/b&gt;&lt;/st1:placename&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; &lt;st1:placetype st="on"&gt;Range&lt;/st1:placetype&gt;&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;: 1970-01-01 &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt; to 2037-12-31 &lt;st1:time minute="59" hour="23" st="on"&gt;23:59:59&lt;/st1:time&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The big difference between DATETIME and TIMESTAMP is the date ranges that can be stored. Below we have purposely entered an erroneous date, manually, so you can see what happens when you enter a date that is outside the boundaries of a this type.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;//This will fail&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_manual = "INSERT INTO dateplayground (dp_name, dp_timestamp)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUES ('TIMESTAMP: Manual Timestamp', '1776-7-4 &lt;st1:time minute="13" hour="16" st="on"&gt;04:13:54&lt;/st1:time&gt;')"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_autodate = "INSERT INTO dateplayground (dp_name, dp_timestamp)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUE ('TIMESTAMP: Auto CURDATE()', CURDATE() )";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: red;"&gt;//This will fail&lt;/span&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_autotime = "INSERT INTO dateplayground (dp_name, dp_timestamp)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUE ('TIMESTAMP: Auto CURTIME()', CURTIME() )"; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_autonow = "INSERT INTO dateplayground (dp_name, dp_timestamp)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUE ('TIMESTAMP: Auto NOW()', NOW() )";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_manual) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_autodate) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_autotime) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_autonow) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Viewing dateplayground in PHP&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Below is a quick script that will spit out the MySQL table dateplayground in HTML.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT * FROM dateplayground";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;table border="'1'"&gt;&lt;tr&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;for($i = 0; $i &lt;&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;th&gt;".mysql_field_name($result, $i)."&lt;/th&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;/tr&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array($result)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;tr&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;for($i = 0; $i &lt;&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;                               &lt;/span&gt;echo "&lt;td&gt;". $row[$i] ."&lt;/td&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;/tr&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;/table&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Finished dateplayground.sql Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;dp_name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;dp_year&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;dp_date&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;dp_datetime&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;dp_timestamp&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;DATE:   Manual Date&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;2020-02-14&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;DATE: Auto   CURDATE()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;2006-09-19&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;YEAR:   Manual Year&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;2011&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;YEAR: Auto   CURDATE()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;2006&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;DATETIME:   Manual DateTime&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;1776-07-04   &lt;st1:time minute="13" hour="16" st="on"&gt;04:13:54&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;DATETIME:   Auto CURDATE()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;2006-09-19   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;DATETIME:   Auto CURTIME()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;DATETIME:   Auto NOW()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;2006-09-19   &lt;st1:time minute="56" hour="16" st="on"&gt;16:56:56&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;TIMESTAMP:   Manual Timestamp&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;TIMESTAMP:   Auto CURDATE()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;2006-09-19   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;TIMESTAMP:   Auto CURTIME()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;TIMESTAMP:   Auto NOW()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;0000-00-00   &lt;st1:time minute="0" hour="0" st="on"&gt;00:00:00&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;2006-09-19   &lt;st1:time minute="56" hour="16" st="on"&gt;16:56:56&lt;/st1:time&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Notice that the rows DATETIME: Auto CURTIME(), TIMESTAMP: Manual Timestamp, and TIMESTAMP: Auto CURTIME() have all zeros. This is because they were the INSERTs that were erroneous. When you enter dates that are out of the range or in the wrong format for a given date type, MySQL will often just enter in the default value of all zeros.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Time - Formats&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;There are three different types of time data types in MySQL: TIME, DATETIME, and TIMESTAMP. If you would like to learn more about DATETIME and TIMESTAMP, then check out our &lt;a href="http://www.tizag.com/mysqlTutorial/mysql-date.php"&gt;&lt;span style="font-size: 8.5pt;"&gt;MySQL Date&lt;/span&gt;&lt;/a&gt; section, as we've covered them there. This lesson will just be covering the basics of using TIME.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Time - TIME&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;First you need to create a MySQL table with a TIME type. We have one already created if you want to use it: &lt;a href="http://www.tizag.com/mysqlTutorial/timeplayground.sql"&gt;&lt;span style="font-size: 8.5pt;"&gt;timeplayground.sql&lt;/span&gt;&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The TIME data type can be used to store actual times as well as the amount of time between two points in time (like the time between now and the weekend) that may sometimes be larger than 23 hours. H - Hour; M - Minute; S - Second.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Standard format&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;: HH:MM:SS &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Extended hour format&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;: HHH:MM:SS &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol; color: black;"&gt;&lt;span style=""&gt;&lt;img src="PicExportError" alt="*" width="10" height="10" /&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;st1:place st="on"&gt;&lt;st1:placename st="on"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Time&lt;/span&gt;&lt;/b&gt;&lt;/st1:placename&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt; &lt;st1:placetype st="on"&gt;Range&lt;/st1:placetype&gt;&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;: -838:59:50 to 838:59:59 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;When manually entering a time into MySQL it is highly recommended that you use the exact format show above. MySQL allows for many different ways to enter a time, but they don't always behave as you would expect. Using the standard/extended format we have shown above will help you avoid annoying problems.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Below we have entered 3 manual times into MySQL. The first is done in the recommended format, the second is a shorthand version of the first and the final example is outside the allowed time range.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;//This assumes you have already created the 'dateplayground' table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;//Connect to DB&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_manual1 = "INSERT INTO timeplayground (dp_name, dp_time)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUES ('TIME: Manual Time', '&lt;st1:time minute="10" hour="12" st="on"&gt;12:10:00&lt;/st1:time&gt;')"; //perfectly done&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_manual2 = "INSERT INTO timeplayground (dp_name, dp_time)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUES ('TIME: Manual Time', '1210')"; // will this shorthand work?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_manual3 = "INSERT INTO timeplayground (dp_name, dp_time)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUES ('TIME: Manual Time', '978:31:12')"; //how about this?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_manual1) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_manual2) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_manual3) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Time - NOW()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;To get the current time, use MySQL's built in function NOW(). NOW() contains both the date and time information, but MySQL is smart enough to just use the data needed for TIME.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query_auto = "INSERT INTO timeplayground (dp_name, dp_time)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;VALUE ('TIME: Auto NOW()', NOW() )";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;mysql_query($query_auto) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL timeplayground.sql Displayed&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Below is a small PHP script to spit out a rough version of our timeplayground.sql table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;PHP &amp;amp; MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;?php&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$query = "SELECT * FROM timeplayground";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;$result = mysql_query($query) or die(mysql_error());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;table border="'1'"&gt;&lt;tr&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;for($i = 0; $i &lt;&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;th&gt;".mysql_field_name($result, $i)."&lt;/th&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;/tr&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;while($row = mysql_fetch_array($result)){&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;tr&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;for($i = 0; $i &lt;&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;                               &lt;/span&gt;echo "&lt;td&gt;". $row[$i] ."&lt;/td&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;span style=""&gt;               &lt;/span&gt;echo "&lt;/tr&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;echo "&lt;/table&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;?&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;Finished timeplayground.sql Display:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;table class="MsoNormalTable" style="" border="1" cellpadding="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;dp_name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal" style="text-align: center;" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;dp_time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;TIME:   Manual Time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;st1:time minute="10" hour="12" st="on"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;12:10:00&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;TIME:   Manual Time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;st1:time minute="12" hour="0" st="on"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;00:12:10&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;TIME:   Manual Time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;838:59:59&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;TIME: Auto   NOW()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0.75pt;"&gt;   &lt;p class="MsoNormal"&gt;&lt;st1:time minute="30" hour="14" st="on"&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;14:30:36&lt;/span&gt;&lt;/st1:time&gt;&lt;span style="font-size: 9.5pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Our first manual time was handled just fine, but our second one did not. MySQL interpreted 1210 as MM:SS instead of HH:MM as we assumed. This is why it's best to use the formats we've described at the beginning.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;The third manual entry was changed from 978:31:12 to 838:59:59, so that it would be within TIME's range.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;&lt;script type="text/javascript"&gt; &lt;!-- google_ad_client = "pub-5396533251015167"; google_ad_width = 468; google_ad_height = 15; google_ad_format = "468x15_0ads_al"; //2007-05-21: Link MySQL google_ad_channel = "0835057552"; google_color_border = "D2E7F4"; google_color_bg = "D2E7F4"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "000000"; //--&gt; &lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt; &lt;/script&gt;&lt;/span&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Index - Overclock Your Tables&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Hardware enthusiasts have been overclocking their PCs for years now, trying to push the limits of their hardware for maximum performance. Sometimes they are successful and their applications run speedy fast, while other times they push a little too hard and end up damaging the computer!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Although it isn't quite as extreme, &lt;b&gt;indexes&lt;/b&gt; in MySQL can increase the speed of your MySQL queries to squeeze a bit more performance out of your database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;MySQL Index - Speed and Extra Overhead&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Indexes are created on a per column basis. If you have a table with the columns: name, age, birthday and employeeID and want to create an index to speed up how long it takes to find &lt;i&gt;employeeID&lt;/i&gt; values in your queries, then you would need to create an index for &lt;i&gt;employeeID&lt;/i&gt;. When you create this index, MySQL will build a lookup index where &lt;i&gt;employeeID&lt;/i&gt; specific queries can be run quickly. However, the name, age and birthday queries would not be any faster.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;Indexes are something extra that you can enable on your MySQL tables to increase performance,cbut they do have some downsides. When you create a new index MySQL builds a separate block of information that needs to be updated every time there are changes made to the table. This means that if you are constantly updating, inserting and removing entries in your table this could have a negative impact on performance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-style: none none dotted; border-color: -moz-use-text-color -moz-use-text-color rgb(10, 67, 105); border-width: medium medium 1pt; padding: 0in;"&gt;  &lt;h1&gt;&lt;span style="font-size: 17pt; font-family: Arial;"&gt;Creating a MySQL Index - New Table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;/div&gt;  &lt;p&gt;&lt;span style="font-size: 9.5pt; font-family: Arial; color: black;"&gt;If you are creating a new MySQL table you can specify a column to index by using the INDEX term as we have below. We have created two fields: name and employeeID (index).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="margin: 7.5pt 0in 0.0001pt;"&gt;&lt;span style="font-size: 12.5pt; color: black;"&gt;MySQL Code:&lt;/span&gt;&lt;span style="font-size: 12.5pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;div style="border: 1.5pt solid rgb(0, 59, 98); padding: 4pt 4pt 15pt; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="border: medium none ; padding: 0in; background: rgb(181, 207, 224) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;span style="font-size: 8.5pt; font-family: Verdana; color: black;"&gt;CREATE TABLE employee_records (&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border:
