<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Code2Design</title>
  <subtitle>Coding and Designing the Best!</subtitle>
  <link rel="alternate" type="text/html" href="http://www.code2design.com"/>
  <link rel="self" type="application/atom+xml" href="http://www.code2design.com/atom/feed"/>
  <id>http://www.code2design.com/atom/feed</id>
  <updated>2007-04-17T23:19:35-04:00</updated>
  <entry>
    <title>Beginning Photo Editing</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/david/beginning_photo_editing" />
    <id>http://www.code2design.com/david/beginning_photo_editing</id>
    <published>2009-05-26T17:19:39-04:00</published>
    <updated>2009-05-26T17:28:08-04:00</updated>
    <author>
      <name>David</name>
    </author>
    <category term="GIMP" />
    <category term="Photos" />
    <category term="Photoshop" />
    <summary type="html"><![CDATA[<!--paging_filter--><p><!--paging_filter-->
<p>Most people are not aware of just how easy it is to enhance even the poorest of photos. In this video I will cover bringing faded photos to life, enhancing colors, repairing dark photos, removing objects we don't want in our pictures, cropping, rotating, and more! At almost 40 minutes long, you will learn the tricks you need to make your photos stand out!</p>
<div class="margin: 0 auto;"><a href="http://www.mindbites.com/lesson/2720-beginning-photo-editing" class="bb-url"><img src="http://code2design.com/system/files/into_screen_v3_500_0.jpg" alt="" class="bb-image" /></a></div>
    ]]></summary>
    <content type="html"><![CDATA[<!--paging_filter--><p>Most people are not aware of just how easy it is to enhance even the poorest of photos. In this video I will cover bringing faded photos to life, enhancing colors, repairing dark photos, removing objects we don't want in our pictures, cropping, rotating, and more! At almost 40 minutes long, you will learn the tricks you need to make your photos stand out!</p>
<div class="margin: 0 auto;"><a href="http://www.mindbites.com/lesson/2720-beginning-photo-editing" class="bb-url"><img src="http://code2design.com/system/files/into_screen_v3_500_0.jpg" alt="" class="bb-image" /></a></div>
<p><!--break--></p>
<p>If you, or someone you know can benefit from this clip please make sure to watch it before June 1st. I entered it into the <a href="http://www.mindbites.com/contests/view/3/all_entries" class="bb-url">cast4cash</a> contest and you have until that date to watch it then it becomes a "pay-to-watch" costing $3 dollars. </p>
<p>Please vote for this video, if I win I will be able to purchase better equipment for future screencasts (Like a good Mic for one!). Also, be sure to check out the rest of the videos on <a href="http://www.mindbites.com/contests/view/3/all_entries" class="bb-url">mindbites</a>.</p>
    ]]></content>
  </entry>
  <entry>
    <title>MicroMVC</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/david/micromvc" />
    <id>http://www.code2design.com/david/micromvc</id>
    <published>2009-02-21T14:29:41-05:00</published>
    <updated>2009-02-21T14:29:41-05:00</updated>
    <author>
      <name>David</name>
    </author>
    <category term="David" />
    <summary type="html"><![CDATA[<p>Today I am happy to announce the release of <a href="http://micromvc.com" class="bb-url">MicroMVC</a> at <a href="http://github.com/Xeoncross/micromvc/" class="bb-url">github</a>. MicroMVC is released under the <a href="http://www.gnu.org/licenses/gpl.html" class="bb-url">GPL v3</a> so it is free for anyone to download and use.<br />
MicroMVC is the project that I am most proud of out of all my web apps. It powers this sites video system and other sites where I needed something lightweight and blazing fast.<br />
Along with the new home it has been updated, cleaned up, and outfitted with a couple example controllers that show you how to fetch twitter updates, create posts in a SQLite database, call hooks/plugins, and load views. There is even a <a href="http://micromvc.com/intro.wmv" class="bb-url">video to help you get started</a>.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>Today I am happy to announce the release of <a href="http://micromvc.com" class="bb-url">MicroMVC</a> at <a href="http://github.com/Xeoncross/micromvc/" class="bb-url">github</a>. MicroMVC is released under the <a href="http://www.gnu.org/licenses/gpl.html" class="bb-url">GPL v3</a> so it is free for anyone to download and use.</p>
<p>MicroMVC is the project that I am most proud of out of all my web apps. It powers this sites video system and other sites where I needed something lightweight and blazing fast.</p>
<p>Along with the new home it has been updated, cleaned up, and outfitted with a couple example controllers that show you how to fetch twitter updates, create posts in a SQLite database, call hooks/plugins, and load views. There is even a <a href="http://micromvc.com/intro.wmv" class="bb-url">video to help you get started</a>.</p>
<p>While this system isn’t for everyone - it is perfect for people that don’t want extra junk in their systems and people who don’t want to deal with a mess of procedural php code everywhere. MicroMVC only requires 5 small files and a controller to work it’s magic. Taking a measly 200kb (or less if caching is on) to run - a lot less than CodeIgniter and Zend which take +2MB and +4MB respectively.</p>
<p>I would love feedback from anyone that would like to try this system out. I hope that it can serve others as much as it has been a help to me. Please feel free to post questions in our forums.</p>
    ]]></content>
  </entry>
  <entry>
    <title>PHP Video Tutorials</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/david/php_video_tutorials" />
    <id>http://www.code2design.com/david/php_video_tutorials</id>
    <published>2008-09-10T11:58:27-04:00</published>
    <updated>2008-09-10T11:58:27-04:00</updated>
    <author>
      <name>David</name>
    </author>
    <category term="David" />
    <summary type="html"><![CDATA[<!--paging_filter--><p><!--paging_filter-->
<p>After several months work I am proud to announce the <a href="http://videos.code2design.com/">Code2Design video system</a> is finally up! Featuring 25 videos on HTML, PHP, AutoCAD, and more! Each video is either 640x480 or 800x600 and is avalible to download for private viewing. (Not everyone has DSL in their home.) </p>
<p>The Two videos I recomend the most are <a href="http://videos.code2design.com/video/play/PHP/11">PHP Security</a> and <a href="http://videos.code2design.com/video/play/Other/1">Resizing and Sending Images For Email</a>.</p>
<p>PHP security is probably the most advanced video of it's type in the world. It is about 45min long and covers basic attacks like Globals, Includes, and Super Global arrays like $_SERVER and $_GET. More advanced subjects like SQL injection, CSFR, and XSS are covered later in the video. Each attack is not only discussed - but actually shown in action so you can easily follow along.</p>
    ]]></summary>
    <content type="html"><![CDATA[<!--paging_filter--><p>After several months work I am proud to announce the <a href="http://videos.code2design.com/">Code2Design video system</a> is finally up! Featuring 25 videos on HTML, PHP, AutoCAD, and more! Each video is either 640x480 or 800x600 and is avalible to download for private viewing. (Not everyone has DSL in their home.) </p>
<p>The Two videos I recomend the most are <a href="http://videos.code2design.com/video/play/PHP/11">PHP Security</a> and <a href="http://videos.code2design.com/video/play/Other/1">Resizing and Sending Images For Email</a>.</p>
<p>PHP security is probably the most advanced video of it's type in the world. It is about 45min long and covers basic attacks like Globals, Includes, and Super Global arrays like $_SERVER and $_GET. More advanced subjects like SQL injection, CSFR, and XSS are covered later in the video. Each attack is not only discussed - but actually shown in action so you can easily follow along.</p>
<p>In addition, you can download the files and replicate the attacks on your own host (before one of my users does it for you). Just look for the "Video Files" link under each video.</p>
<p>I hope you enjoy the videos and please leave feedback on what you would like to see next!</p>
    ]]></content>
  </entry>
  <entry>
    <title>MD5, hashes, passwords, salts and more</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/david/md5_hashes_passwords_salts_and_more" />
    <id>http://www.code2design.com/david/md5_hashes_passwords_salts_and_more</id>
    <published>2008-04-08T16:04:30-04:00</published>
    <updated>2008-04-08T16:04:54-04:00</updated>
    <author>
      <name>David</name>
    </author>
    <category term="PHP" />
    <category term="Hacking" />
    <summary type="html"><![CDATA[<p>1) You need to salt your passwords.<br />
"Assume a user's secret key is stolen and he is known to use one of 200,000 English words as his password. The system uses a 32-bit salt (like md5). Because of this salt, the attacker's pre-calculated hashes are of no value. He/she must calculate the hash of each word with each of 2^32 (4,294,967,296) possible salts appended until a match is found. The total number of possible inputs can be obtained by multiplying the number of words in the dictionary with the number of possible salts:<br />
2^{32} \times 200 000 = 8.58993459 \times 10^{14}<br />
To complete a brute-force attack, the attacker must now compute about 800 trillion hashes, instead of only 200,000. Even though the password itself is known to be simple, the secret salt makes breaking the password radically more difficult." - <a href="http://en.wikipedia.org/wiki/Salt_"><a href="http://en.wikipedia.org/wiki/Salt_">http://en.wikipedia.org/wiki/Salt_</a></a>(cryptography)</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>1) You need to salt your passwords.</p>
<p>"Assume a user's secret key is stolen and he is known to use one of 200,000 English words as his password. The system uses a 32-bit salt (like md5). Because of this salt, the attacker's pre-calculated hashes are of no value. He/she must calculate the hash of each word with each of 2^32 (4,294,967,296) possible salts appended until a match is found. The total number of possible inputs can be obtained by multiplying the number of words in the dictionary with the number of possible salts:</p>
<p>2^{32} \times 200 000 = 8.58993459 \times 10^{14}</p>
<p>To complete a brute-force attack, the attacker must now compute about 800 trillion hashes, instead of only 200,000. Even though the password itself is known to be simple, the secret salt makes breaking the password radically more difficult." - <a href="http://en.wikipedia.org/wiki/Salt_">http://en.wikipedia.org/wiki/Salt_</a>(cryptography)</p>
<p>2) Now that I got that off my chest I recommend this awesome PHP class <a href="http://www.openwall.com/phpass/">http://www.openwall.com/phpass/</a> as even WORDPRESS has started using it.</p>
<p>3) Plain md5 is just too simple to crack - it is like WEP in WIFI: <a href="http://md5.rednoize.com/">http://md5.rednoize.com/</a></p>
<p>4) Rainbow Tables can kill your simple PHP scripts: <a href="http://www.antsight.com/zsl/rainbowcrack/">http://www.antsight.com/zsl/rainbowcrack/</a><br />
<a href="http://en.wikipedia.org/wiki/Rainbow_table">http://en.wikipedia.org/wiki/Rainbow_table</a></p>
<p>So please, I don't want to see anyone still using plain md5() hashes - at least use a salt! </p>
<p><a href="http://www.lightbluetouchpaper.org/2007/11/16/google-as-a-password-cracker/">http://www.lightbluetouchpaper.org/2007/11/16/google-as-a-password-cracker/</a><br />
<a href="http://phpsec.org/articles/2005/password-hashing.html">http://phpsec.org/articles/2005/password-hashing.html</a></p>
    ]]></content>
  </entry>
  <entry>
    <title>Arrays by reference</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/tutorial/arrays_by_reference" />
    <id>http://www.code2design.com/tutorial/arrays_by_reference</id>
    <published>2008-01-17T15:18:24-05:00</published>
    <updated>2008-01-17T15:27:53-05:00</updated>
    <author>
      <name>David</name>
    </author>
    <category term="Beginning PHP Tutorials" />
    <summary type="html"><![CDATA[<!--paging_filter--><p><!--paging_filter-->
<p>I have been using lots of functions to create and check my variables and arrays lately. Along these lines, I thought I would take some time to share how the concept of "passing values by reference" works. </p>
<p>Basically, if you are anything like me you are always passing functions values and then having that function "return" a value. While there is nothing wrong with this approach, there is often an easier way to work with values in functions. Besides making values "<a href="http://us.php.net/global">global</a>", you can also pass a function a value by reference.</p>
<p>Here is the standard way most people would work with a value in a function and then collect the functions return value.</p>
    ]]></summary>
    <content type="html"><![CDATA[<!--paging_filter--><p>I have been using lots of functions to create and check my variables and arrays lately. Along these lines, I thought I would take some time to share how the concept of "passing values by reference" works. </p>
<p>Basically, if you are anything like me you are always passing functions values and then having that function "return" a value. While there is nothing wrong with this approach, there is often an easier way to work with values in functions. Besides making values "<a href="http://us.php.net/global">global</a>", you can also pass a function a value by reference.</p>
<p>Here is the standard way most people would work with a value in a function and then collect the functions return value.</p>
<p><!--break--></p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br /><br /></font><font color="#FF8000">////////////////////////////////<br />//&nbsp;Standard&nbsp;Function<br />////////////////////////////////<br /><br />//Lets&nbsp;create&nbsp;a&nbsp;variable;<br /></font><font color="#0000BB">$my_variable&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">''</font><font color="#007700">;<br /><br /></font><font color="#FF8000">//Create&nbsp;the&nbsp;"add_key"&nbsp;function<br /></font><font color="#007700">function&nbsp;</font><font color="#0000BB">add_key</font><font color="#007700">(</font><font color="#0000BB">$key</font><font color="#007700">)&nbsp;{<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; </font><font color="#FF8000">//Create&nbsp;an&nbsp;new&nbsp;array();<br />&nbsp; &nbsp; </font><font color="#0000BB">$array&nbsp;</font><font color="#007700">=&nbsp;array();<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; </font><font color="#FF8000">//Ad&nbsp;a&nbsp;key&nbsp;called&nbsp;"new_key"&nbsp;to&nbsp;the&nbsp;array<br />&nbsp; &nbsp; </font><font color="#0000BB">$array</font><font color="#007700">[</font><font color="#0000BB">$key</font><font color="#007700">]&nbsp;=&nbsp;</font><font color="#DD0000">'value'</font><font color="#007700">;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; </font><font color="#FF8000">//return&nbsp;the&nbsp;$array<br />&nbsp; &nbsp; </font><font color="#007700">return&nbsp;</font><font color="#0000BB">$array</font><font color="#007700">;<br />}<br /><br /></font><font color="#FF8000">//Run&nbsp;the&nbsp;function&nbsp;"add_key()"&nbsp;and&nbsp;place&nbsp;the&nbsp;output&nbsp;into&nbsp;<br />//$my_variable&nbsp;turning&nbsp;it&nbsp;from&nbsp;an&nbsp;empty&nbsp;variable,&nbsp;into&nbsp;an&nbsp;array!<br />//In&nbsp;other&nbsp;words,&nbsp;$my_variable&nbsp;is&nbsp;now&nbsp;an&nbsp;array&nbsp;with&nbsp;1&nbsp;key&nbsp;called&nbsp;"new_key";<br /></font><font color="#0000BB">$my_variable&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">add_key</font><font color="#007700">(</font><font color="#DD0000">'new_key'</font><font color="#007700">);<br /><br /><br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>$my_variable is now an array ready for you to use in the rest of your script. If you were to run the <a href="http://php.net/print_r" target="_blank">print_r()</a> function right now you would see that $my_variable looks like the following to PHP.</p>
<p><div class="codeblock"><code>Array <br />(<br />    [new_key] =&gt; value<br />)</code></div></p>
<p>So now that we're all "on-the-same-page" so to speak, I want to show you how you can use PHP to cut out a little junk from your script. First though, we need to cover the "&amp;" (and) character. The "&amp;" character means that you aren't working with the variable/array/etc. - you are only working with a pointer to that variable/array/etc. In other words, if you mess with something that has a "&amp;" in front of it you are following that $variables sign to another variables value in the computers memory and changing it!</p>
<blockquote><p>
References in PHP are a means to access the same variable content by different names... ...Note that in PHP, variable name and variable content are different, so the same content can have different names. - <a href="http://php.net">php.net</a>
</p></blockquote>
<p>If you are lost look at this:<br />
<div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br /><br />$foo&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">'Hello'</font><font color="#007700">;<br /></font><font color="#0000BB">$bar&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">'World'</font><font color="#007700">;&nbsp;<br />print&nbsp;</font><font color="#0000BB">$foo&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#DD0000">"&nbsp;"&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">$bar</font><font color="#007700">;<br /></font><font color="#FF8000">//Prints&nbsp;"Hello&nbsp;World"<br /><br />//Change&nbsp;$bar&nbsp;to&nbsp;equal&nbsp;"Hello&nbsp;My&nbsp;World"<br /></font><font color="#0000BB">$bar&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">'Hello&nbsp;My&nbsp;World'</font><font color="#007700">;<br /></font><font color="#FF8000">//Change&nbsp;$foo&nbsp;to&nbsp;equal&nbsp;the&nbsp;value&nbsp;of&nbsp;a&nbsp;variable&nbsp;called&nbsp;"$bar"<br /></font><font color="#0000BB">$foo&nbsp;</font><font color="#007700">=&nbsp;&amp;</font><font color="#0000BB">$bar</font><font color="#007700">;<br /><br />print&nbsp;</font><font color="#0000BB">$foo</font><font color="#007700">;<br /></font><font color="#FF8000">//Finds&nbsp;the&nbsp;value&nbsp;of&nbsp;$bar,&nbsp;and&nbsp;Prints&nbsp;"Hello&nbsp;My&nbsp;World"<br /></font><font color="#007700">print&nbsp;</font><font color="#0000BB">$bar</font><font color="#007700">;<br /></font><font color="#FF8000">//Prints&nbsp;"Hello&nbsp;My&nbsp;World"<br /><br />//Change&nbsp;$bar&nbsp;to&nbsp;equal&nbsp;"This&nbsp;is&nbsp;bar"<br /></font><font color="#0000BB">$bar&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">'This&nbsp;is&nbsp;bar'</font><font color="#007700">;<br /><br />print&nbsp;</font><font color="#0000BB">$foo</font><font color="#007700">;<br /></font><font color="#FF8000">//Finds&nbsp;the&nbsp;value&nbsp;of&nbsp;$bar,&nbsp;and&nbsp;Prints&nbsp;"This&nbsp;is&nbsp;bar"<br /></font><font color="#007700">print&nbsp;</font><font color="#0000BB">$bar</font><font color="#007700">;<br /></font><font color="#FF8000">//Prints&nbsp;"This&nbsp;is&nbsp;bar"<br /><br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>As you can see, from now on $foo will always be eqaul to whatever $bar is equal too! This is quite a useful feature if it is used in the right way! </p>
<p>Taking our first block of code lets change it to use this new type of "variable reference" thinking.<br />
<div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br /><br /></font><font color="#FF8000">////////////////////////////////<br />//&nbsp;Simple&nbsp;Function&nbsp;Reference<br />////////////////////////////////<br /><br />//Lets&nbsp;create&nbsp;a&nbsp;variable;<br /></font><font color="#0000BB">$my_variable&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">''</font><font color="#007700">;<br /><br /></font><font color="#FF8000">//Create&nbsp;the&nbsp;"add_key"&nbsp;function&nbsp;and&nbsp;set&nbsp;the<br />//value&nbsp;of&nbsp;to&nbsp;$array&nbsp;to&nbsp;whatever&nbsp;variable&nbsp;was&nbsp;given<br />//to&nbsp;the&nbsp;function.<br /></font><font color="#007700">function&nbsp;</font><font color="#0000BB">add_key2</font><font color="#007700">(&amp;</font><font color="#0000BB">$array</font><font color="#007700">,&nbsp;</font><font color="#0000BB">$key</font><font color="#007700">)&nbsp;{<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; </font><font color="#FF8000">//This&nbsp;now&nbsp;changes&nbsp;$my_variable&nbsp;into&nbsp;an&nbsp;array<br />&nbsp; &nbsp; </font><font color="#0000BB">$array&nbsp;</font><font color="#007700">=&nbsp;array();<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; </font><font color="#FF8000">//Ad&nbsp;a&nbsp;key&nbsp;called&nbsp;"new_key"&nbsp;to&nbsp;$array,&nbsp;which&nbsp;points&nbsp;to&nbsp;$my_variable<br />&nbsp; &nbsp; //So&nbsp;add&nbsp;a&nbsp;new&nbsp;key&nbsp;to&nbsp;$my_variable!<br />&nbsp; &nbsp; </font><font color="#0000BB">$array</font><font color="#007700">[</font><font color="#0000BB">$key</font><font color="#007700">]&nbsp;=&nbsp;</font><font color="#DD0000">'value'</font><font color="#007700">;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; </font><font color="#FF8000">//There&nbsp;is&nbsp;nothing&nbsp;to&nbsp;return&nbsp;so&nbsp;we&nbsp;don't&nbsp;need&nbsp;this.<br />&nbsp; &nbsp; //return&nbsp;$array;<br /></font><font color="#007700">}<br /><br /></font><font color="#FF8000">//Run&nbsp;the&nbsp;function&nbsp;"add_key2()"&nbsp;which&nbsp;works&nbsp;with&nbsp;a&nbsp;reference&nbsp;to&nbsp;<br />//$my_variable&nbsp;in&nbsp;real&nbsp;time&nbsp;so&nbsp;when&nbsp;add_key&nbsp;is&nbsp;done&nbsp;running,&nbsp;<br />//$my_variable&nbsp;is&nbsp;already&nbsp;updated!<br /></font><font color="#0000BB">add_key2</font><font color="#007700">(</font><font color="#0000BB">$my_variable</font><font color="#007700">,&nbsp;</font><font color="#DD0000">'new_key'</font><font color="#007700">);<br /><br /><br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>$my_variable was transformed into an array by add_key2. Because the first part of the function had a "&amp;" in front of the value to pass the function. That &amp; means that whenever add_key2 worked with "$array", it was really working with "$my_variable"! If you were to run the <a href="http://php.net/print_r" target="_blank">print_r()</a> function right now you would see that $my_variable looks like the following to PHP.</p>
<p><div class="codeblock"><code>Array <br />(<br />    [new_key] =&gt; value<br />)</code></div></p>
<p>So both methods accomplish the same thing just in different ways. Below is a more complex function I built for <a href="http://codexplorer.com">CodeXplorer</a> that will add values to any array you tell it. You might need to download it and run it if you have trouble following the code.</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br /><br /><br /></font><font color="#FF8000">////////////////////////////////<br />//&nbsp;Complex&nbsp;Function&nbsp;Reference<br />////////////////////////////////<br /><br /><br />///////////////////////////////////////////////////////////<br />//&nbsp;A&nbsp;function&nbsp;to&nbsp;set&nbsp;multiple&nbsp;array&nbsp;variables&nbsp;if&nbsp;they&nbsp;don't&nbsp;exist.<br />///////////////////////////////////////////////////////////<br /></font><font color="#007700">function&nbsp;</font><font color="#0000BB">create_array_keys</font><font color="#007700">(&amp;</font><font color="#0000BB">$array</font><font color="#007700">,&nbsp;</font><font color="#0000BB">$keys</font><font color="#007700">,&nbsp;</font><font color="#0000BB">$value</font><font color="#007700">=</font><font color="#DD0000">''</font><font color="#007700">)&nbsp;{<br />&nbsp; &nbsp; foreach&nbsp;(</font><font color="#0000BB">$keys&nbsp;</font><font color="#007700">as&nbsp;</font><font color="#0000BB">$key</font><font color="#007700">)&nbsp;{<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#FF8000">//if&nbsp;the&nbsp;key&nbsp;is&nbsp;not&nbsp;in&nbsp;the&nbsp;array,&nbsp;create&nbsp;it!<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#007700">if&nbsp;(!</font><font color="#0000BB">array_key_exists</font><font color="#007700">(</font><font color="#0000BB">$key</font><font color="#007700">,&nbsp;</font><font color="#0000BB">$array</font><font color="#007700">))&nbsp;{&nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">$array</font><font color="#007700">[</font><font color="#0000BB">$key</font><font color="#007700">]&nbsp;=&nbsp;</font><font color="#0000BB">$value</font><font color="#007700">;&nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; </font><font color="#FF8000">//There&nbsp;is&nbsp;nothing&nbsp;to&nbsp;return&nbsp;(everything&nbsp;is&nbsp;done&nbsp;by&nbsp;reference).<br /></font><font color="#007700">}<br /><br /></font><font color="#FF8000">//Create&nbsp;my&nbsp;empty&nbsp;array<br /></font><font color="#0000BB">$my_array&nbsp;</font><font color="#007700">=&nbsp;array();<br /><br /></font><font color="#FF8000">//create&nbsp;an&nbsp;array&nbsp;of&nbsp;keys&nbsp;I&nbsp;want&nbsp;to&nbsp;add&nbsp;to&nbsp;the&nbsp;array<br /></font><font color="#0000BB">$keys&nbsp;</font><font color="#007700">=&nbsp;array(</font><font color="#DD0000">'key_1'</font><font color="#007700">,&nbsp;</font><font color="#DD0000">'key_2'</font><font color="#007700">,&nbsp;</font><font color="#DD0000">'key_3'</font><font color="#007700">,&nbsp;</font><font color="#DD0000">'key_4'</font><font color="#007700">);<br /><br /></font><font color="#FF8000">//See&nbsp;what&nbsp;$my_array&nbsp;looks&nbsp;like<br /></font><font color="#007700">print&nbsp;</font><font color="#DD0000">'&lt;pre&gt;'</font><font color="#007700">;<br /></font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">$my_array</font><font color="#007700">);<br />print&nbsp;</font><font color="#DD0000">'&lt;/pre&gt;'</font><font color="#007700">;<br /><br /></font><font color="#FF8000">//If&nbsp;the&nbsp;following&nbsp;values&nbsp;are&nbsp;not&nbsp;set,&nbsp;create&nbsp;them&nbsp;in&nbsp;the&nbsp;array&nbsp;"$my_array"&nbsp;and&nbsp;set&nbsp;them&nbsp;to&nbsp;"TRUE".<br /></font><font color="#0000BB">create_array_keys</font><font color="#007700">(</font><font color="#0000BB">$my_array</font><font color="#007700">,&nbsp;</font><font color="#0000BB">$keys</font><font color="#007700">,&nbsp;</font><font color="#0000BB">true</font><font color="#007700">);<br /><br /></font><font color="#FF8000">//See&nbsp;what&nbsp;$my_array&nbsp;looks&nbsp;like&nbsp;now!<br /></font><font color="#007700">print&nbsp;</font><font color="#DD0000">'&lt;pre&gt;'</font><font color="#007700">;<br /></font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">$my_array</font><font color="#007700">);<br />print&nbsp;</font><font color="#DD0000">'&lt;/pre&gt;'</font><font color="#007700">;<br /><br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>If you ran the above code you would see the following output.<br />
<div class="codeblock"><code>&lt;pre&gt;<br />Array<br />(<br />)<br />&lt;/pre&gt;<br />&lt;pre&gt;<br />Array<br />(<br />    [key_1] =&gt; 1<br />    [key_2] =&gt; 1<br />    [key_3] =&gt; 1<br />    [key_4] =&gt; 1<br />)<br />&lt;/pre&gt;</code></div></p>
<p>So I hope this lesson helps you to better understand how to use PHP's powerful references to avoid having to pass variables around different functions. With references you can simply run a function and know that the variable is being updated automatically. If you want more information on this topic you can visit the PHP manual at <a href="http://us3.php.net/manual/en/functions.arguments.php#functions.arguments.by-reference" target="_blank">php.net - Arguments passed by reference</a> and <a href="http://us3.php.net/manual/en/language.references.php">php.net - References Explained</a>.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Convert MySQL Tables to SQLite Tables</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/tutorial/convert_mysql_tables_to_sqlite_tables" />
    <id>http://www.code2design.com/tutorial/convert_mysql_tables_to_sqlite_tables</id>
    <published>2007-12-13T15:36:36-05:00</published>
    <updated>2007-12-13T16:34:19-05:00</updated>
    <author>
      <name>David</name>
    </author>
    <category term="Databases" />
    <summary type="html"><![CDATA[<!--paging_filter--><p><!--paging_filter-->
<p>If you are having trouble converting <a href="http://www.mysql.com/">MySQL</a> tables to <a href="http://sqlite.org">SQLite</a> tables then this tutorial is for you. On the other hand, if you have no idea what I just said then let me explain that both MySQL and SQLite are free, open source databases. While MySQL is the most used open source database in the world, SQLite is catching on as a great database for people who don't need a complex system to manage their data. I personally have been looking into it as a possibility for running my personal blog.</p>
    ]]></summary>
    <content type="html"><![CDATA[<!--paging_filter--><p>If you are having trouble converting <a href="http://www.mysql.com/">MySQL</a> tables to <a href="http://sqlite.org">SQLite</a> tables then this tutorial is for you. On the other hand, if you have no idea what I just said then let me explain that both MySQL and SQLite are free, open source databases. While MySQL is the most used open source database in the world, SQLite is catching on as a great database for people who don't need a complex system to manage their data. I personally have been looking into it as a possibility for running my personal blog.</p>
<blockquote><p>SQLite is an embedded SQL database engine. Unlike most other SQL databases, SQLite does not have a separate server process. SQLite reads and writes directly to ordinary disk files. A complete SQL database with multiple tables, indices, triggers, and views, is contained in a single disk file. The database file format is cross-platform - you can freely copy a database between 32-bit and 64-bit systems or between big-endian and little-endian architectures. These features make SQLite a popular choice as an Application File Format. Think of SQLite not as a replacement for Oracle but as a replacement for fopen(). - the SQLite site
</p></blockquote>
<p>Anyway, if you have already started working with SQLite but have encountered problems with SQL syntax - I would like to explain some of the main differences in creating a table. Lets start with a basic MySQL table.</p>
<p><div class="codeblock"><code>/* Table structure for mySQL table */<br /><br />CREATE TABLE `tablename` (<br />    `id` int(11) NOT NULL auto_increment,<br />    `title` text NOT NULL default &#039;&#039;,<br />    `text` text NOT NULL,<br />    `time` int(10) NOT NULL default &#039;0000000000&#039;,<br />    UNIQUE KEY `id` (`id`),<br />) TYPE=MyISAM;</code></div></p>
<p>If you try to just port that over into SQLite - you'll get so many errors it's not funny. First lets start with the "INT" column type. In SQLite it is "INTEGER" not "INT". So, that is the first thing that needs to be changed.</p>
<p>Second, in SQLite "auto_increment" is a given if the key is a <b>PRIMARY KEY</b>. So we can delete the "auto_increment" part of the MySQL query. This now leaves us with the following:</p>
<p><div class="codeblock"><code>-- Table structure for NEW SQLite table<br />CREATE TABLE `tablename` (<br />    `id` INTEGER NOT NULL ,<br />    `title` text NOT NULL default &#039;&#039;,<br />    `text` text NOT NULL,<br />    `time` INTEGER NOT NULL default &#039;0000000000&#039;,<br />    UNIQUE KEY `id` (`id`),<br />) TYPE=MyISAM;</code></div></p>
<p>Third, we don't need the "<b>UNIQUE KEY `id` (`id`),</b>" line. In SQLite, that data goes on the same line as the item that is set to the "PRIMARY KEY".</p>
<p><div class="codeblock"><code>-- Table structure for NEW SQLite table<br />CREATE TABLE `tablename` (<br />    `id` INTEGER PRIMARY KEY NOT NULL ,<br />    `title` text NOT NULL default &#039;&#039;,<br />    `text` text NOT NULL,<br />    `time` INTEGER NOT NULL default &#039;0000000000&#039;,<br />) TYPE=MyISAM;</code></div></p>
<p>Forth, remove the bottom " TYPE=MyISAM" as there is no such type in SQLite. In MySQL you can chose from one of several DB types. However, SQLite only has 1 type - so there is no need to specify it.</p>
<p>Now the last thing we need to do is get rid of the " ` " characters in the code as SQLite doesn't like them in queries. So we just replace all the " ` " with double-quotes (NOT single quotes). You can also just leave them off as they are NOT required. Also, delete the ending comma. Our final output is:</p>
<p><div class="codeblock"><code>-- Table structure for NEW SQLite table<br />CREATE TABLE &quot;tablename&quot; (<br />    &quot;id&quot; INTEGER PRIMARY KEY NOT NULL ,<br />    &quot;title&quot; text NOT NULL default &quot;&quot;,<br />    &quot;text&quot; text NOT NULL,<br />    &quot;time&quot; INTEGER NOT NULL default &quot;0000000000&quot;<br />);</code></div></p>
<p>The following tables show how you can use double-quotes in any order without fear of trouble:</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br /><br />$query&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">'CREATE&nbsp;TABLE&nbsp;temp2&nbsp;(<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id&nbsp;INTEGER&nbsp;PRIMARY&nbsp;KEY&nbsp;NOT&nbsp;NULL,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title&nbsp;TEXT&nbsp;NOT&nbsp;NULL&nbsp;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text&nbsp;TEXT&nbsp;NOT&nbsp;NULL&nbsp;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time&nbsp;INTEGER&nbsp;NOT&nbsp;NULL<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<br />CREATE&nbsp;TABLE&nbsp;"temp3"&nbsp;(<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "id"&nbsp;INTEGER&nbsp;PRIMARY&nbsp;KEY&nbsp;NOT&nbsp;NULL,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "title"&nbsp;TEXT&nbsp;NOT&nbsp;NULL&nbsp;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "text"&nbsp;TEXT&nbsp;NOT&nbsp;NULL&nbsp;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "time"&nbsp;INTEGER&nbsp;NOT&nbsp;NULL<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<br />CREATE&nbsp;TABLE&nbsp;temp4&nbsp;(<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "id"&nbsp;INTEGER&nbsp;PRIMARY&nbsp;KEY&nbsp;NOT&nbsp;NULL,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "title"&nbsp;TEXT&nbsp;NOT&nbsp;NULL&nbsp;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "text"&nbsp;TEXT&nbsp;NOT&nbsp;NULL&nbsp;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "time"&nbsp;INTEGER&nbsp;NOT&nbsp;NULL<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<br />CREATE&nbsp;TABLE&nbsp;temp5&nbsp;(<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id&nbsp;INTEGER&nbsp;PRIMARY&nbsp;KEY&nbsp;NOT&nbsp;NULL,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "title"&nbsp;TEXT&nbsp;NOT&nbsp;NULL&nbsp;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text&nbsp;TEXT&nbsp;NOT&nbsp;NULL&nbsp;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "time"&nbsp;INTEGER&nbsp;NOT&nbsp;NULL<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );'</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p><a href="http://sqlite.org/lang.html">SQL As Understood By SQLite</a> is a great read for anyone who wants to check advanced queries against the SQL standard. The <a href="http://www.sqlite.org/cvstrac/wiki?p=ManagementTools">SQLite Wiki</a> also has a great list of command-line &amp; desktop programs that you can use to create SQLite tables for you if you are still unsure about all this. I personally like <a href="http://sqliteman.com/">SQLiteMan</a> as I can create the database and tables right on my Windows desktop and then export a SQL Schema for use in my php scripts.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Members-system (using My-Sql)</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/tutorial/members_system_using_my_sql" />
    <id>http://www.code2design.com/tutorial/members_system_using_my_sql</id>
    <published>2007-08-29T13:32:08-04:00</published>
    <updated>2008-01-17T15:28:59-05:00</updated>
    <author>
      <name>Alxandr</name>
    </author>
    <category term="Membership and User Authentication" />
    <summary type="html"><![CDATA[<h3>PHP and MySQL login-system</h3>
<p>Here I will teach you how to create a really basic login-system for use in php and mysql. The system can easily be built on to work with flash and other applications.<br />
I'll just start:<br />
First you need a "data.php" file that looks like this:<br />
<code>&lt;font color=&quot;#000000&quot;&gt;&lt;font color=&quot;#0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&amp;nbsp;&lt;br /&gt;$dbc&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;=&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;mysql_connect&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#DD0000&quot;&gt;&quot;localhost&quot;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;,&lt;/font&gt;&lt;font color=&quot;#DD0000&quot;&gt;&quot;***username***&quot;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;,&lt;/font&gt;&lt;font color=&quot;#DD0000&quot;&gt;&quot;***password***&quot;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;);&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;mysql_select_db&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#DD0000&quot;&gt;&quot;***db_name***&quot;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;);&amp;nbsp;&lt;br /&gt;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;session_start&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;();&lt;br /&gt;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;?&amp;gt;&lt;/font&gt;&lt;/font&gt;</code><br />
You also need a database with a table (registered) with fields that look like the SQL code below. (If you want, you can copy it into phpMyAdmin and it will create the table.)<br />
<code>CREATE TABLE `registered` (&lt;br /&gt;  `id` int(11) NOT NULL auto_increment,&lt;br /&gt;  `username` varchar(64) NOT NULL,&lt;br /&gt;  `password` varchar(32) NOT NULL,&lt;br /&gt;  PRIMARY KEY  (`id`)&lt;br /&gt;) DEFAULT CHARSET=utf8;</code></p>
    ]]></summary>
    <content type="html"><![CDATA[<h3>PHP and MySQL login-system</h3>
<p>Here I will teach you how to create a really basic login-system for use in php and mysql. The system can easily be built on to work with flash and other applications.</p>
<p>I'll just start:</p>
<p>First you need a "data.php" file that looks like this:</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br />&nbsp;<br />$dbc&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_connect</font><font color="#007700">(</font><font color="#DD0000">"localhost"</font><font color="#007700">,</font><font color="#DD0000">"***username***"</font><font color="#007700">,</font><font color="#DD0000">"***password***"</font><font color="#007700">);&nbsp;</font><font color="#0000BB">mysql_select_db</font><font color="#007700">(</font><font color="#DD0000">"***db_name***"</font><font color="#007700">);&nbsp;<br /></font><font color="#0000BB">session_start</font><font color="#007700">();<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>You also need a database with a table (registered) with fields that look like the SQL code below. (If you want, you can copy it into phpMyAdmin and it will create the table.)<br />
<div class="codeblock"><code>CREATE TABLE `registered` (<br />  `id` int(11) NOT NULL auto_increment,<br />  `username` varchar(64) NOT NULL,<br />  `password` varchar(32) NOT NULL,<br />  PRIMARY KEY  (`id`)<br />) DEFAULT CHARSET=utf8;</code></div></p>
<p>Then (in the main file) we need to include the "data.php"-file:</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br /></font><font color="#007700">include&nbsp;</font><font color="#DD0000">"data.php"</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br /></font><font color="#007700">function&nbsp;</font><font color="#0000BB">loginForm</font><font color="#007700">(){<br /></font><font color="#0000BB">?&gt;</font></font></code></div><div class="codeblock"><code>&lt;form method=&quot;post&quot;&gt;<br />&lt;strong&gt;Username:&lt;/strong&gt; &lt;input type=&quot;text&quot; name=&quot;login[username]&quot; /&gt;&lt;br /&gt;<br />&lt;strong&gt;Password:&lt;/strong&gt; &lt;input type=&quot;password&quot; name=&quot;login[password]&quot; /&gt;&lt;br /&gt;<br />&lt;input type=&quot;submit&quot; /&gt;<br />&lt;/form&gt;</code></div><br />
<div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br />&nbsp; &nbsp; </font><font color="#007700">}<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>Now what this does, is that if we ever run the function loginForm() it will output all that HTML there (which of course just is a basic form).</p>
<p>Then we need to make a is_logged_in() function. The code for that should be:</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br />&nbsp; &nbsp; </font><font color="#007700">function&nbsp;</font><font color="#0000BB">is_logged_in</font><font color="#007700">(){<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#FF8000">//isset&nbsp;will&nbsp;return&nbsp;TRUE&nbsp;or&nbsp;FALSE<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#007700">return&nbsp;isset(</font><font color="#0000BB">$_SESSION</font><font color="#007700">[</font><font color="#DD0000">'loggedIn'</font><font color="#007700">]);<br />&nbsp; &nbsp; }<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>All this function does is to return whether or not the variable $_SESSION['loggedIn'] is set or not. If it is set - return true. If the session is NOT set - return false.</p>
<p>Now we need to make a function that tells us whether or not the user is trying to login.</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br />&nbsp; &nbsp; </font><font color="#007700">function&nbsp;</font><font color="#0000BB">is_logging_in</font><font color="#007700">(){<br />&nbsp; &nbsp; &nbsp; &nbsp; return&nbsp;isset(</font><font color="#0000BB">$_POST</font><font color="#007700">[</font><font color="#DD0000">'login'</font><font color="#007700">]);<br />&nbsp; &nbsp; }<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>This will return true if the post-variable <span style="font-weight:bold">login</span> is set (remember, we put the input field inside an array named login... name="login[username]").</p>
<p>Now we need a function to do the login...</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br />&nbsp; &nbsp; </font><font color="#007700">function&nbsp;</font><font color="#0000BB">login</font><font color="#007700">(</font><font color="#0000BB">$username</font><font color="#007700">,&nbsp;</font><font color="#0000BB">$md5password</font><font color="#007700">){<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">$query&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">'SELECT&nbsp;*&nbsp;FROM&nbsp;`registered`&nbsp;WHERE&nbsp;`username`&nbsp;=&nbsp;\''</font><font color="#007700">.</font><font color="#0000BB">mysql_real_escape_string</font><font color="#007700">(</font><font color="#0000BB">$username</font><font color="#007700">).&nbsp;</font><font color="#DD0000">'\'&nbsp;AND&nbsp;password&nbsp;=&nbsp;\''</font><font color="#007700">.&nbsp;</font><font color="#0000BB">mysql_real_escape_string</font><font color="#007700">(</font><font color="#0000BB">$md5password</font><font color="#007700">).&nbsp;</font><font color="#DD0000">'\''</font><font color="#007700">;<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">$rs&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#0000BB">$query</font><font color="#007700">);<br />&nbsp; &nbsp; &nbsp; &nbsp; if(!</font><font color="#0000BB">mysql_num_rows</font><font color="#007700">(</font><font color="#0000BB">$rs</font><font color="#007700">)){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo&nbsp;</font><font color="#DD0000">"&lt;strong&gt;Bad&nbsp;login!&lt;/strong&gt;&lt;br&nbsp;/&gt;"</font><font color="#007700">;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">loginForm</font><font color="#007700">();&nbsp;</font><font color="#FF8000">//here&nbsp;we&nbsp;ask&nbsp;the&nbsp;user&nbsp;to&nbsp;login&nbsp;again...<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#007700">die();<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; while(</font><font color="#0000BB">$row&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_fetch_assoc</font><font color="#007700">(</font><font color="#0000BB">$rs</font><font color="#007700">)){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(</font><font color="#0000BB">$username&nbsp;</font><font color="#007700">==&nbsp;</font><font color="#0000BB">$row</font><font color="#007700">[</font><font color="#DD0000">'username'</font><font color="#007700">]&nbsp;&amp;&amp;&nbsp;</font><font color="#0000BB">$md5password&nbsp;</font><font color="#007700">==&nbsp;</font><font color="#0000BB">$row</font><font color="#007700">[</font><font color="#DD0000">'password'</font><font color="#007700">]){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">$_SESSION</font><font color="#007700">[</font><font color="#DD0000">'loggedIn'</font><font color="#007700">]&nbsp;=&nbsp;</font><font color="#0000BB">true</font><font color="#007700">;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die(</font><font color="#DD0000">"&lt;script&nbsp;language=\"javascript\"&gt;window.location.reload();&lt;/script&gt;"</font><font color="#007700">);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; echo&nbsp;</font><font color="#DD0000">"&lt;strong&gt;Bad&nbsp;login!&lt;/strong&gt;&lt;br&nbsp;/&gt;"</font><font color="#007700">;<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">loginForm</font><font color="#007700">();<br />&nbsp; &nbsp; &nbsp; &nbsp; die();<br />&nbsp; &nbsp; }<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>Than we need a function to deal with what to do is to create a function to manage what to happen if the user is logged in:</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br />&nbsp; &nbsp; </font><font color="#007700">function&nbsp;</font><font color="#0000BB">loggedIn</font><font color="#007700">(){<br />&nbsp; &nbsp; &nbsp; &nbsp; die(</font><font color="#DD0000">"&lt;h1&gt;You&nbsp;are&nbsp;logged&nbsp;in!&lt;/h1&gt;"</font><font color="#007700">);<br />&nbsp; &nbsp; }<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>Ok... Now we just need to structure everything out...</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br />&nbsp; &nbsp; </font><font color="#007700">if(</font><font color="#0000BB">is_logged_in</font><font color="#007700">()){<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">loggedIn</font><font color="#007700">();<br />&nbsp; &nbsp; }&nbsp;elseif(</font><font color="#0000BB">is_logging_in</font><font color="#007700">()){<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">login</font><font color="#007700">(</font><font color="#0000BB">$_POST</font><font color="#007700">[</font><font color="#DD0000">'login'</font><font color="#007700">][</font><font color="#DD0000">'username'</font><font color="#007700">],&nbsp;</font><font color="#0000BB">md5</font><font color="#007700">(</font><font color="#0000BB">$_POST</font><font color="#007700">[</font><font color="#DD0000">'login'</font><font color="#007700">][</font><font color="#DD0000">'password'</font><font color="#007700">]));<br />&nbsp; &nbsp; }&nbsp;else&nbsp;{<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">loginForm</font><font color="#007700">();<br />&nbsp; &nbsp; }<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>All the code now looks like this:</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br />&nbsp; &nbsp; </font><font color="#007700">include&nbsp;</font><font color="#DD0000">"data.php"</font><font color="#007700">;<br />&nbsp; &nbsp; function&nbsp;</font><font color="#0000BB">loginForm</font><font color="#007700">(){<br /></font><font color="#0000BB">?&gt;</font></font></code></div><br />
<div class="codeblock"><code>&lt;form method=&quot;post&quot;&gt;<br />&lt;strong&gt;Username:&lt;/strong&gt; &lt;input type=&quot;text&quot; name=&quot;login[username]&quot; /&gt;&lt;br /&gt;<br />&lt;strong&gt;Password:&lt;/strong&gt; &lt;input type=&quot;password&quot; name=&quot;login[password]&quot; /&gt;&lt;br /&gt;<br />&lt;input type=&quot;submit&quot; /&gt;<br />&lt;/form&gt;</code></div><br />
<div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br />&nbsp; &nbsp; </font><font color="#007700">}<br />&nbsp; &nbsp; function&nbsp;</font><font color="#0000BB">is_logged_in</font><font color="#007700">(){<br />&nbsp; &nbsp; &nbsp; &nbsp; return&nbsp;isset(</font><font color="#0000BB">$_SESSION</font><font color="#007700">[</font><font color="#DD0000">'loggedIn'</font><font color="#007700">]);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; function&nbsp;</font><font color="#0000BB">is_logging_in</font><font color="#007700">(){<br />&nbsp; &nbsp; &nbsp; &nbsp; return&nbsp;isset(</font><font color="#0000BB">$_POST</font><font color="#007700">[</font><font color="#DD0000">'login'</font><font color="#007700">]);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; function&nbsp;</font><font color="#0000BB">login</font><font color="#007700">(</font><font color="#0000BB">$username</font><font color="#007700">,&nbsp;</font><font color="#0000BB">$md5password</font><font color="#007700">){<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">$query&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">'SELECT&nbsp;*&nbsp;FROM&nbsp;`registered`&nbsp;WHERE&nbsp;`username`&nbsp;=&nbsp;\''</font><font color="#007700">.</font><font color="#0000BB">mysql_real_escape_string</font><font color="#007700">(</font><font color="#0000BB">$username</font><font color="#007700">).&nbsp;</font><font color="#DD0000">'\'&nbsp;AND&nbsp;password&nbsp;=&nbsp;\''</font><font color="#007700">.&nbsp;</font><font color="#0000BB">mysql_real_escape_string</font><font color="#007700">(</font><font color="#0000BB">$md5password</font><font color="#007700">).&nbsp;</font><font color="#DD0000">'\''</font><font color="#007700">;<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">$rs&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#0000BB">$query</font><font color="#007700">);<br />&nbsp; &nbsp; &nbsp; &nbsp; if(!</font><font color="#0000BB">mysql_num_rows</font><font color="#007700">(</font><font color="#0000BB">$rs</font><font color="#007700">)){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo&nbsp;</font><font color="#DD0000">"&lt;strong&gt;Bad&nbsp;login!&lt;/strong&gt;&lt;br&nbsp;/&gt;"</font><font color="#007700">;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">loginForm</font><font color="#007700">();&nbsp;</font><font color="#FF8000">//here&nbsp;we&nbsp;ask&nbsp;the&nbsp;user&nbsp;to&nbsp;login&nbsp;again...<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#007700">die();<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; while(</font><font color="#0000BB">$row&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_fetch_assoc</font><font color="#007700">(</font><font color="#0000BB">$rs</font><font color="#007700">)){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(</font><font color="#0000BB">$username&nbsp;</font><font color="#007700">==&nbsp;</font><font color="#0000BB">$row</font><font color="#007700">[</font><font color="#DD0000">'username'</font><font color="#007700">]&nbsp;&amp;&amp;&nbsp;</font><font color="#0000BB">$md5password&nbsp;</font><font color="#007700">==&nbsp;</font><font color="#0000BB">$row</font><font color="#007700">[</font><font color="#DD0000">'password'</font><font color="#007700">]){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">$_SESSION</font><font color="#007700">[</font><font color="#DD0000">'loggedIn'</font><font color="#007700">]&nbsp;=&nbsp;</font><font color="#0000BB">true</font><font color="#007700">;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die(</font><font color="#DD0000">"&lt;script&nbsp;language=\"javascript\"&gt;window.location.reload();&lt;/script&gt;"</font><font color="#007700">);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; echo&nbsp;</font><font color="#DD0000">"&lt;strong&gt;Bad&nbsp;login!&lt;/strong&gt;&lt;br&nbsp;/&gt;"</font><font color="#007700">;<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">loginForm</font><font color="#007700">();<br />&nbsp; &nbsp; &nbsp; &nbsp; die();<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; function&nbsp;</font><font color="#0000BB">loggedIn</font><font color="#007700">(){<br />&nbsp; &nbsp; &nbsp; &nbsp; die(</font><font color="#DD0000">"&lt;h1&gt;You&nbsp;are&nbsp;loged&nbsp;in!&lt;/h1&gt;"</font><font color="#007700">);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; </font><font color="#FF8000">//here&nbsp;komes&nbsp;the&nbsp;logic...<br />&nbsp; &nbsp; </font><font color="#007700">if(</font><font color="#0000BB">is_logged_in</font><font color="#007700">()){<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">loggedIn</font><font color="#007700">();<br />&nbsp; &nbsp; }&nbsp;elseif(</font><font color="#0000BB">is_logging_in</font><font color="#007700">()){<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">login</font><font color="#007700">(</font><font color="#0000BB">$_POST</font><font color="#007700">[</font><font color="#DD0000">'login'</font><font color="#007700">][</font><font color="#DD0000">'username'</font><font color="#007700">],&nbsp;</font><font color="#0000BB">md5</font><font color="#007700">(</font><font color="#0000BB">$_POST</font><font color="#007700">[</font><font color="#DD0000">'login'</font><font color="#007700">][</font><font color="#DD0000">'password'</font><font color="#007700">]));<br />&nbsp; &nbsp; }&nbsp;else&nbsp;{<br />&nbsp; &nbsp; &nbsp; &nbsp; </font><font color="#0000BB">loginForm</font><font color="#007700">();<br />&nbsp; &nbsp; }<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
    ]]></content>
  </entry>
  <entry>
    <title>Javascript tooltips</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/tutorial/javascript_tooltips" />
    <id>http://www.code2design.com/tutorial/javascript_tooltips</id>
    <published>2007-06-02T13:51:51-04:00</published>
    <updated>2007-06-09T12:51:19-04:00</updated>
    <author>
      <name>Alxandr</name>
    </author>
    <summary type="html"><![CDATA[<!--paging_filter--><p><!--paging_filter--><br />
<h4>Easy tooltips using javascript and html</h4>
<style>
<!--
body { background-color: #ffffff; color: #000000; }
pre { font-family: "Courier New",Courier,monospace; font-size: 12px; color: #000000; }
span.comment { color: #777777; font-weight: normal; }
span.oper { color: #8d7f07; font-weight: bold; }
span.var { color: #008080; font-weight: normal; }
span.func { color: #aa00ff; font-weight: bold; }
span.string { color: #990000; font-weight: normal; }
span.num { color: #990000; font-weight: bold; }
span.reg { color: #990000; font-weight: normal; }
-->
</style><p>Today I'm gone teach you how to create tooltips in HTML. First of all, you need to let the computer know that we are writing javascript - So start by typing:</p>
<div class="codeblock"><code>&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/script&amp;gt;;</code></div>
</p>
<p>Now that we have the container for the javascript we can now add the actual code for the tooltips. Paste this inside the script tags:</p>
    ]]></summary>
    <content type="html"><![CDATA[<!--paging_filter--><h4>Easy tooltips using javascript and html</h4>
<style>
<!--
body { background-color: #ffffff; color: #000000; }
pre { font-family: "Courier New",Courier,monospace; font-size: 12px; color: #000000; }
span.comment { color: #777777; font-weight: normal; }
span.oper { color: #8d7f07; font-weight: bold; }
span.var { color: #008080; font-weight: normal; }
span.func { color: #aa00ff; font-weight: bold; }
span.string { color: #990000; font-weight: normal; }
span.num { color: #990000; font-weight: bold; }
span.reg { color: #990000; font-weight: normal; }
-->
</style><p>Today I'm gone teach you how to create tooltips in HTML. First of all, you need to let the computer know that we are writing javascript - So start by typing:<br />
<div class="codeblock"><code>&lt;script language=&quot;javascript&quot;&gt;<br /><br />&lt;/script&gt;;</code></div></p>
<p>Now that we have the container for the javascript we can now add the actual code for the tooltips. Paste this inside the script tags:</p>
<pre><span class="oper">var</span> <span class="var">ns4</span> <span class="oper">=</span> <span class="var">document</span>.<span class="var">layers</span>;
<span class="oper">var</span> <span class="var">ns6</span> <span class="oper">=</span> <span class="var">document</span>.<span class="var">getElementById</span> <span class="oper">&amp;</span><span class="oper">&amp;</span> <span class="oper">!</span><span class="var">document</span>.<span class="var">all</span>;
<span class="oper">var</span> <span class="var">ie4</span> <span class="oper">=</span> <span class="var">document</span>.<span class="var">all</span>;
<span class="var">offsetX</span> <span class="oper">=</span> <span class="num">05</span>;
<span class="var">offsetY</span> <span class="oper">=</span> <span class="num">20</span>;
<span class="oper">var</span> <span class="var">toolTipSTYLE</span> <span class="oper">=</span> &quot;<span class="string"></span>&quot;;
<span class="oper">function</span> <span class="func">initToolTips</span>() {
	<span class="oper">var</span> <span class="var">ttarea</span> <span class="oper">=</span> <span class="var">document</span>.<span class="func">createElement</span>('<span class="string">div</span>');
	<span class="var">ttarea</span>.<span class="func">setAttribute</span>('<span class="string">id</span>','<span class="string">toolTipLayer</span>');
	<span class="var">ttarea</span>.<span class="var">style</span>.<span class="var">position</span> <span class="oper">=</span> &quot;<span class="string">absolute</span>&quot;;
	<span class="var">ttarea</span>.<span class="var">style</span>.<span class="var">width</span> <span class="oper">=</span> &quot;<span class="string">250px</span>&quot;;
	<span class="oper">if</span>(<span class="var">document</span>.<span class="var">appendChild</span>){
		<span class="var">document</span>.<span class="var">body</span>.<span class="func">appendChild</span>(<span class="var">ttarea</span>);
	} <span class="oper">else</span> {
		<span class="func">alert</span>(&quot;<span class="string">Your browser does not support the script used at this page, pleas switch browser</span>&quot;);	
	}
	<span class="oper">if</span>(<span class="var">ns4</span><span class="oper">|</span><span class="oper">|</span><span class="var">ns6</span><span class="oper">|</span><span class="oper">|</span><span class="var">ie4</span>) {
		<span class="oper">if</span>(<span class="var">ns4</span>) {
			<span class="var">toolTipSTYLE</span> <span class="oper">=</span> <span class="var">document</span>.<span class="var">toolTipLayer</span>;
		} <span class="oper">else</span> <span class="oper">if</span>(<span class="var">ns6</span>) {
			<span class="var">toolTipSTYLE</span> <span class="oper">=</span> <span class="var">document</span>.<span class="func">getElementById</span>(&quot;<span class="string">toolTipLayer</span>&quot;).<span class="var">style</span>;
		} <span class="oper">else</span> <span class="oper">if</span>(<span class="var">ie4</span>) {
			<span class="var">toolTipSTYLE</span> <span class="oper">=</span> <span class="var">document</span>.<span class="var">all</span>.<span class="var">toolTipLayer</span>.<span class="var">style</span>;
		}
		<span class="oper">if</span>(<span class="var">ns4</span>) {
			<span class="var">document</span>.<span class="func">captureEvents</span>(<span class="var">Event</span>.<span class="var">MOUSEMOVE</span>);
		} <span class="oper">else</span> {
			<span class="var">toolTipSTYLE</span>.<span class="var">visibility</span> <span class="oper">=</span> &quot;<span class="string">visible</span>&quot;;
			<span class="var">toolTipSTYLE</span>.<span class="var">display</span> <span class="oper">=</span> &quot;<span class="string">none</span>&quot;;
		}
		<span class="var">document</span>.<span class="var">onmousemove</span> <span class="oper">=</span> <span class="var">moveToMouseLoc</span>;
	}
}
<span class="oper">function</span> <span class="func">toolTip</span>(<span class="var">msg</span>, <span class="var">fg</span>, <span class="var">bg</span>, <span class="var">border</span>)
{
	<span class="oper">if</span>(<span class="var">toolTip</span>.<span class="var">arguments</span>.<span class="var">length</span> <span class="oper">&lt;</span> <span class="num">1</span>) {
		<span class="oper">if</span>(<span class="var">ns4</span>) {
			<span class="var">toolTipSTYLE</span>.<span class="var">visibility</span> <span class="oper">=</span> &quot;<span class="string">hidden</span>&quot;;
		} <span class="oper">else</span> {
			<span class="var">toolTipSTYLE</span>.<span class="var">display</span> <span class="oper">=</span> &quot;<span class="string">none</span>&quot;;
		}
	} <span class="oper">else</span> {
		<span class="oper">if</span>(<span class="oper">!</span><span class="var">fg</span>) {
			<span class="var">fg</span> <span class="oper">=</span> &quot;<span class="string">#777777</span>&quot;;
		}
		<span class="oper">if</span>(<span class="oper">!</span><span class="var">bg</span>) {
			<span class="var">bg</span> <span class="oper">=</span> &quot;<span class="string">#FFFFFF</span>&quot;;
		}
		<span class="oper">if</span>(<span class="oper">!</span><span class="var">border</span>){
			<span class="var">border</span> <span class="oper">=</span> <span class="var">fg</span>;	
		}
		<span class="oper">var</span> <span class="var">content</span> <span class="oper">=</span> '<span class="string">&lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;1&quot; bgcolor=&quot;</span>';
		<span class="var">content</span> <span class="oper">+</span><span class="oper">=</span> <span class="var">border</span>;
		<span class="var">content</span> <span class="oper">+</span><span class="oper">=</span> '<span class="string">&quot;&gt;&lt;td&gt;</span>';
		<span class="var">content</span> <span class="oper">+</span><span class="oper">=</span> '<span class="string">&lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;1&quot; bgcolor=&quot;</span>';
		<span class="var">content</span> <span class="oper">+</span><span class="oper">=</span> <span class="var">bg</span>;
		<span class="var">content</span> <span class="oper">+</span><span class="oper">=</span> '<span class="string">&quot;&gt;&lt;td align=&quot;center&quot;&gt;&lt;font face=&quot;sans-serif&quot; color=&quot;</span>';
		<span class="var">content</span> <span class="oper">+</span><span class="oper">=</span> <span class="var">fg</span>;
		<span class="var">content</span> <span class="oper">+</span><span class="oper">=</span> '<span class="string">&quot; size=&quot;-2&quot;&gt;&amp;nbsp\;</span>';
		<span class="var">content</span> <span class="oper">+</span><span class="oper">=</span> <span class="var">msg</span>;
		<span class="var">content</span> <span class="oper">+</span><span class="oper">=</span> '<span class="string">&amp;nbsp\;&lt;/font&gt;&lt;/td&gt;&lt;/table&gt;&lt;/td&gt;&lt;/table&gt;</span>';
		<span class="oper">if</span>(<span class="var">ns4</span>) {
			<span class="var">toolTipSTYLE</span>.<span class="var">document</span>.<span class="func">write</span>(<span class="var">content</span>);
			<span class="var">toolTipSTYLE</span>.<span class="var">document</span>.<span class="func">close</span>();
			<span class="var">toolTipSTYLE</span>.<span class="var">visibility</span> <span class="oper">=</span> &quot;<span class="string">visible</span>&quot;;
		}
		<span class="oper">if</span>(<span class="var">ns6</span>) {
			<span class="var">document</span>.<span class="func">getElementById</span>(&quot;<span class="string">toolTipLayer</span>&quot;).<span class="var">innerHTML</span> <span class="oper">=</span> <span class="var">content</span>;
			<span class="var">toolTipSTYLE</span>.<span class="var">display</span> <span class="oper">=</span> '<span class="string">block</span>';
		}
		<span class="oper">if</span>(<span class="var">ie4</span>) {
			<span class="var">document</span>.<span class="func">all</span>(&quot;<span class="string">toolTipLayer</span>&quot;).<span class="var">innerHTML</span><span class="oper">=</span><span class="var">content</span>;
			<span class="var">toolTipSTYLE</span>.<span class="var">display</span><span class="oper">=</span>'<span class="string">block</span>';
		}
	}
}
<span class="oper">function</span> <span class="func">moveToMouseLoc</span>(<span class="var">e</span>) {
	<span class="oper">if</span>(<span class="var">ns4</span><span class="oper">|</span><span class="oper">|</span><span class="var">ns6</span>) {
		<span class="var">x</span> <span class="oper">=</span> <span class="var">e</span>.<span class="var">pageX</span>;
		<span class="var">y</span> <span class="oper">=</span> <span class="var">e</span>.<span class="var">pageY</span>;
	} <span class="oper">else</span> {
		<span class="var">x</span> <span class="oper">=</span> <span class="var">event</span>.<span class="var">x</span> <span class="oper">+</span> <span class="var">document</span>.<span class="var">body</span>.<span class="var">scrollLeft</span>;
		<span class="var">y</span> <span class="oper">=</span> <span class="var">event</span>.<span class="var">y</span> <span class="oper">+</span> <span class="var">document</span>.<span class="var">body</span>.<span class="var">scrollTop</span>;
	}
	<span class="var">toolTipSTYLE</span>.<span class="var">left</span> <span class="oper">=</span> <span class="var">x</span> <span class="oper">+</span> <span class="var">offsetX</span>;
	<span class="var">toolTipSTYLE</span>.<span class="var">top</span> <span class="oper">=</span> <span class="var">y</span> <span class="oper">+</span> <span class="var">offsetY</span>;
	<span class="oper">return</span> <span class="num">true</span>;
}
<span class="oper">function</span> <span class="func">setToolTip</span>(<span class="var">object</span>, <span class="var">msg</span>, <span class="var">fg</span>, <span class="var">bg</span>, <span class="var">border</span>){
	<span class="oper">if</span>(<span class="var">setToolTip</span>.<span class="var">arguments</span>.<span class="var">length</span> <span class="oper">&lt;</span> <span class="num">2</span>) {
		<span class="oper">return</span> <span class="num">false</span>;
	} <span class="oper">else</span> {
		<span class="oper">switch</span> (<span class="var">setToolTip</span>.<span class="var">arguments</span>.<span class="var">length</span>) {
			<span class="oper">case</span> <span class="num">2</span><span class="oper">:</span>
				<span class="var">object</span>.<span class="var">onmouseover</span> <span class="oper">=</span> <span class="oper">function</span>(){
					<span class="func">toolTip</span>(<span class="var">msg</span>);	
				}
				<span class="oper">break</span>;
			<span class="oper">case</span> <span class="num">3</span><span class="oper">:</span>
				<span class="var">object</span>.<span class="var">onmouseover</span> <span class="oper">=</span> <span class="oper">function</span>(){
					<span class="func">toolTip</span>(<span class="var">msg</span>, <span class="var">fg</span>);	
				}
				<span class="oper">break</span>;
			<span class="oper">case</span> <span class="num">4</span><span class="oper">:</span>
				<span class="var">object</span>.<span class="var">onmouseover</span> <span class="oper">=</span> <span class="oper">function</span>(){
					<span class="func">toolTip</span>(<span class="var">msg</span>, <span class="var">fg</span>, <span class="var">bg</span>);	
				}
				<span class="oper">break</span>;
			<span class="oper">case</span> <span class="num">5</span><span class="oper">:</span>
				<span class="var">object</span>.<span class="var">onmouseover</span> <span class="oper">=</span> <span class="oper">function</span>(){
					<span class="func">toolTip</span>(<span class="var">msg</span>, <span class="var">fg</span>, <span class="var">bg</span>, <span class="var">border</span>);	
				}
				<span class="oper">break</span>;
			<span class="oper">default</span><span class="oper">:</span>
				<span class="var">object</span>.<span class="var">onmouseover</span> <span class="oper">=</span> <span class="oper">function</span>(){
					<span class="func">toolTip</span>(<span class="var">msg</span>, <span class="var">fg</span>, <span class="var">bg</span>);	
				}
				<span class="oper">break</span>;
		}
		<span class="var">object</span>.<span class="var">onmouseout</span> <span class="oper">=</span> <span class="oper">function</span>(){
			<span class="func">toolTip</span>();	
		}
	}
}
<span class="func">initToolTips</span>();</pre><p>
Don't bother trying to understand everything that happens, even I don't... But what is importent now is that to create a tooltip to a spessific object you can use one out of two methods... The first one is to add this attributes to a already existing html-tag: <div class="codeblock"><code>onmouseover=&quot;tooltip(&#039;text&#039;,&#039;#forgroundcollor&#039;,&#039;#backgroundcolor&#039;,&#039;#bordercolor&#039;);&quot; onmouseout=&quot;tooltip();&quot;</code></div><br />
Now of couse this won't work because #forgrondcollor isn't a valid collor, you need to use valid collors for every field that starts with an '#'. Aditionaly you only need to add one parameter, then the code looks like this:<br />
<div class="codeblock"><code>onmouseover=&quot;tooltip(&#039;text&#039;);&quot; onmouseout=&quot;tooltip();&quot;</code></div><br />
The second method is to add id to every element that you wan't to create a tooltip belonging to and then at the very bottom of the page (just before the closing &lt;body&gt; tag you can add this script: </p>
<pre>
&lt;script language="javascript"&gt;
&nbsp;&nbsp;&nbsp;&nbsp;<span class="func">setToolTip</span>(<span class="var">document</span>.<span class="func">getElementById</span>(&quot;<span class="string">theId</span>&quot;), &quot;<span class="string">text</span>&quot;);
&lt;/script&gt; </pre><p>
And that's it, you're done!</p>
    ]]></content>
  </entry>
  <entry>
    <title>SELECT COUNT from database</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/tutorial/select_count_from_database" />
    <id>http://www.code2design.com/tutorial/select_count_from_database</id>
    <published>2007-05-13T20:16:42-04:00</published>
    <updated>2007-05-13T20:17:15-04:00</updated>
    <author>
      <name>David</name>
    </author>
    <category term="Databases" />
    <summary type="html"><![CDATA[<!--paging_filter--><p><!--paging_filter-->
<p>I thought I would just take a minute to share this little code snippet with you as I had some trouble finding posts online that would tell me if I was going about this the right way! The problem is that I needed a fast way to <span style="font-weight:bold">count how many rows were in a database</span> without using a CPU demanding function like <a href="http://php.net/mysql_num_rows">mysql_num_rows()</a>.</p>
<p>
<div class="codeblock"><code>&lt;font color=&quot;#000000&quot;&gt;&lt;font color=&quot;#0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$query&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;=&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#DD0000&quot;&gt;&#039;SELECT&amp;nbsp;COUNT(*)&amp;nbsp;FROM&amp;nbsp;`users`&#039;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;;&lt;br /&gt;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;$result&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;=&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;mysql_query&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;$query&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;)&amp;nbsp;or&amp;nbsp;die(&lt;/font&gt;&lt;font color=&quot;#DD0000&quot;&gt;&#039;Sorry,&amp;nbsp;we&amp;nbsp;could&amp;nbsp;not&amp;nbsp;count&amp;nbsp;the&amp;nbsp;number&amp;nbsp;of&amp;nbsp;results:&amp;nbsp;&#039;&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;.&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;mysql_error&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;());&lt;br /&gt;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;$numberofresults&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;=&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;mysql_result&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;$result&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;,&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;0&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;);&lt;br /&gt;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;?&amp;gt;&lt;/font&gt;&lt;/font&gt;</code></div>
</p>
<p>You can also limit the count to only rows that meet a certain value:</p>
<div class="codeblock"><code>&lt;font color=&quot;#000000&quot;&gt;&lt;font color=&quot;#0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/font&gt;&lt;font color=&quot;#FF8000&quot;&gt;//Where&amp;nbsp;the&amp;nbsp;user&amp;nbsp;id&amp;nbsp;is&amp;nbsp;greater&amp;nbsp;than&amp;nbsp;149.&lt;br /&gt;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;$query&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;=&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#DD0000&quot;&gt;&#039;SELECT&amp;nbsp;COUNT(*)&amp;nbsp;FROM&amp;nbsp;`your_table`&amp;nbsp;WHERE&amp;nbsp;`id`&amp;nbsp;&amp;gt;&amp;nbsp;149&#039;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;;&lt;br /&gt;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;$result&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;=&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;mysql_query&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;$query&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;)&amp;nbsp;or&amp;nbsp;die(&lt;/font&gt;&lt;font color=&quot;#DD0000&quot;&gt;&#039;Sorry,&amp;nbsp;we&amp;nbsp;could&amp;nbsp;not&amp;nbsp;count&amp;nbsp;the&amp;nbsp;number&amp;nbsp;of&amp;nbsp;results:&amp;nbsp;&#039;&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;.&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;mysql_error&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;());&lt;br /&gt;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;$numberofresults&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;=&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;mysql_result&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;(&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;$result&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;,&amp;nbsp;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;0&lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;);&lt;br /&gt;&lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;?&amp;gt;&lt;/font&gt;&lt;/font&gt;</code></div>
</p>
    ]]></summary>
    <content type="html"><![CDATA[<!--paging_filter--><p>I thought I would just take a minute to share this little code snippet with you as I had some trouble finding posts online that would tell me if I was going about this the right way! The problem is that I needed a fast way to <span style="font-weight:bold">count how many rows were in a database</span> without using a CPU demanding function like <a href="http://php.net/mysql_num_rows">mysql_num_rows()</a>.</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br />$query&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">'SELECT&nbsp;COUNT(*)&nbsp;FROM&nbsp;`users`'</font><font color="#007700">;<br /></font><font color="#0000BB">$result&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#0000BB">$query</font><font color="#007700">)&nbsp;or&nbsp;die(</font><font color="#DD0000">'Sorry,&nbsp;we&nbsp;could&nbsp;not&nbsp;count&nbsp;the&nbsp;number&nbsp;of&nbsp;results:&nbsp;'&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">mysql_error</font><font color="#007700">());<br /></font><font color="#0000BB">$numberofresults&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_result</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">,&nbsp;</font><font color="#0000BB">0</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>You can also limit the count to only rows that meet a certain value:<br />
<div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">//Where&nbsp;the&nbsp;user&nbsp;id&nbsp;is&nbsp;greater&nbsp;than&nbsp;149.<br /></font><font color="#0000BB">$query&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#DD0000">'SELECT&nbsp;COUNT(*)&nbsp;FROM&nbsp;`your_table`&nbsp;WHERE&nbsp;`id`&nbsp;&gt;&nbsp;149'</font><font color="#007700">;<br /></font><font color="#0000BB">$result&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_query</font><font color="#007700">(</font><font color="#0000BB">$query</font><font color="#007700">)&nbsp;or&nbsp;die(</font><font color="#DD0000">'Sorry,&nbsp;we&nbsp;could&nbsp;not&nbsp;count&nbsp;the&nbsp;number&nbsp;of&nbsp;results:&nbsp;'&nbsp;</font><font color="#007700">.&nbsp;</font><font color="#0000BB">mysql_error</font><font color="#007700">());<br /></font><font color="#0000BB">$numberofresults&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">mysql_result</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">,&nbsp;</font><font color="#0000BB">0</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>Keep in mind that this is for counting all the <span style="font-weight:bold">rows</span> in the table. For example, if you had a database like this with 40 of your "users" in it:<br />
<div class="codeblock"><code>CREATE TABLE `users` (<br />  `id` int(11) NOT NULL auto_increment,<br />  `username` varchar(20) NOT NULL default &#039;&#039;,<br />  `password` varchar(20) NOT NULL default &#039;&#039;,<br />  `email` varchar(70) NOT NULL default &#039;&#039;,<br />)</code></div><br />
Even though there are 4 fields in each members row - the result of the above script will only output "<span style="font-weight:bold">40</span>" not "160". Because while there are a total of 160 columns in all - there are only 40 users (each with the above four columns in their row).</p>
<p>Remember, it is slower to select a single field (<span style="font-weight:bold">SELECT COUNT(id)FROM `users`</span>) than it is to just count the whole thing (<span style="font-weight:bold">SELECT COUNT(*)FROM `users`</span>). Because MySQL already knows how many rows are in each database - so it can just tell you. But if you specify a certain field - then MySQL has to open each row and look around for that field.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Free AutoDesk Inventor</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/david/free_autodesk_inventor" />
    <id>http://www.code2design.com/david/free_autodesk_inventor</id>
    <published>2007-04-19T18:05:08-04:00</published>
    <updated>2007-04-19T18:05:08-04:00</updated>
    <author>
      <name>David</name>
    </author>
    <category term="AutoCAD" />
    <category term="Site News" />
    <summary type="html"><![CDATA[<p><a href="http://autodesk.com/">AutoDesk</a> is giving away free copies of its student programs like <a href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;id=4246282">AutoDesk Inventor</a>. If you are a student you need to take a minute to register for this great offer! (visit <a href="http://students3.autodesk.com/">Student Autodesk</a>)<br />
As soon as my month-long fight with my computer-box is over (Curse you SATA, Cheap Video Cards, and ECS Mobos), I plan on releasing some Inventor tutorials and because it is a $4000 program (Full Version) this maybe your only chance to grab a copy!<br />
Please note that you must be a student with a college email address(I think they also allow Highschool emails). Also, you will need a decent video card for this program as it is a 3D modeling program. (64MB video card should be fine - but I suggest a 128MB.)</p>
    ]]></summary>
    <content type="html"><![CDATA[<p><a href="http://autodesk.com/">AutoDesk</a> is giving away <span style="font-weight:bold">free copies</span> of its student programs like <a href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;id=4246282">AutoDesk Inventor</a>. If you are a student you <span style="font-style:italic">need</span> to take a minute to register for this great offer! (visit <a href="http://students3.autodesk.com/">Student Autodesk</a>) </p>
<p>As soon as my month-long fight with my computer-box is over (Curse you SATA, Cheap Video Cards, and ECS Mobos), I plan on releasing some Inventor tutorials and because it is a $4000 program (Full Version) this maybe your only chance to grab a copy! </p>
<p>Please note that you must be a student with a college email address(I think they also allow Highschool emails). Also, you will need a decent video card for this program as it is a 3D modeling program. (64MB video card should be fine - but I suggest a 128MB.)</p>
    ]]></content>
  </entry>
  <entry>
    <title>Simple 3 Column</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/simple_3_column" />
    <id>http://www.code2design.com/simple_3_column</id>
    <published>2007-04-17T21:13:57-04:00</published>
    <updated>2007-04-17T23:47:41-04:00</updated>
    <author>
      <name>David</name>
    </author>
    <summary type="html"><![CDATA[<!--paging_filter--><p><!--paging_filter-->
<p>After traveling around looking at sites that hurt my eyes I thought I would put together a basic template that is good-looking, XHTML valid with 3-Columns, and yet simple enough that you can easily navigate the page.</p>
<p>So here is a Cross-Browser compatible design that I have tested in IE6 &amp; 7, Firefox 2, and Opera 9. You can see it live here: <a href="http://webn.ws/simple3column/" target="_blank">Simple 3 Column</a></p>
<p>Now, the point of this design isn't necessarily for you to just have something through up on your site - but for you to have a basic design to work off of and to hack into your own custom creation. That is why I have included <span style="font-weight:bold">TWO</span> style sheets with this theme. The default is "pretty.css" but if you plan on using the layout as a basis for your own design I recommend you open "index.html" and change the style sheet from "pretty.css" to "simple.css". Because the simple style sheet is cleaner and easy to follow for those changing things...</p>
    ]]></summary>
    <content type="html"><![CDATA[<!--paging_filter--><p>After traveling around looking at sites that hurt my eyes I thought I would put together a basic template that is good-looking, XHTML valid with 3-Columns, and yet simple enough that you can easily navigate the page.</p>
<p>So here is a Cross-Browser compatible design that I have tested in IE6 &amp; 7, Firefox 2, and Opera 9. You can see it live here: <a href="http://webn.ws/simple3column/" target="_blank">Simple 3 Column</a></p>
<p>Now, the point of this design isn't necessarily for you to just have something through up on your site - but for you to have a basic design to work off of and to hack into your own custom creation. That is why I have included <span style="font-weight:bold">TWO</span> style sheets with this theme. The default is "pretty.css" but if you plan on using the layout as a basis for your own design I recommend you open "index.html" and change the style sheet from "pretty.css" to "simple.css". Because the simple style sheet is cleaner and easy to follow for those changing things...</p>
<p>Remember, keep the content area clean, white, and simple - there <span style="font-weight:bold">is</span> a reason the top websites do it this way. ;)</p>
<p>If you want to change the width of the layout check out <a href="http://code2design.com/understanding_css_dimensions">this post on dimensions</a>.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Understanding CSS Dimensions</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/tutorial/understanding_css_dimensions" />
    <id>http://www.code2design.com/tutorial/understanding_css_dimensions</id>
    <published>2007-04-17T15:24:35-04:00</published>
    <updated>2007-04-17T23:06:36-04:00</updated>
    <author>
      <name>David</name>
    </author>
    <category term="Dimensions" />
    <category term="Padding" />
    <summary type="html"><![CDATA[<p>If you have ever taken a dive into the CSS code of a layout you liked - only to find something like this:<br />
<code>.object {&lt;br /&gt;    margin: 0px auto 20px .8%;&lt;br /&gt;    padding: 0em 25px;&lt;br /&gt;}</code><br />
Then this tutorial is for you - because today I am going to explain the strange dimension system built into CSS! :)<br />
Now first off, how many of you have ever be at a lost as to the direction you were going? Or have to think for a minute to figure out where West is from North? Even more to the point - how many of you have ever heard the old saying "Never Eat Soggy Waffles"? (No, quite that! - I didn't make it up!) Well, for all us humans without GPS systems - this saying stands for "North East South West" which is the clock-wise order of the directions.<br />
<code>---N---&lt;br /&gt;W-----E&lt;br /&gt;---S---</code><br />
Well, CSS also uses the clockwise order of directions. Take a look at the following code:<br />
When you see something like:<br />
<code>.object {&lt;br /&gt;    padding: 10px 25px 5px 0px;&lt;br /&gt;}</code></p>
    ]]></summary>
    <content type="html"><![CDATA[<p>If you have ever taken a dive into the CSS code of a layout you liked - only to find something like this:<br />
<div class="codeblock"><code>.object {<br />    margin: 0px auto 20px .8%;<br />    padding: 0em 25px;<br />}</code></div><br />
Then this tutorial is for you - because today I am going to explain the strange dimension system built into CSS! :)</p>
<p>Now first off, how many of you have ever be at a lost as to the direction you were going? Or have to think for a minute to figure out where West is from North? Even more to the point - how many of you have ever heard the old saying "Never Eat Soggy Waffles"? (No, quite that! - I didn't make it up!) Well, for all us humans without GPS systems - this saying stands for "North East South West" which is the clock-wise order of the directions.<br />
<div class="codeblock"><code>---N---<br />W-----E<br />---S---</code></div><br />
Well, CSS also uses the clockwise order of directions. Take a look at the following code:</p>
<p>When you see something like:<br />
<div class="codeblock"><code>.object {<br />    padding: 10px 25px 5px 0px;<br />}</code></div><br />
If it were in English it would say:<br />
<div class="codeblock"><code>.object {<br />padding (is): 10pixels(top) 25pixels(right) 5pixels(bottom) 0pixels(on left);<br />}<br />.object {<br />padding (is): 10pixels(North) 25pixels(East) 5pixels(South) 0pixels(West);<br />}</code></div></p>
<p>So just remember that the first element is the top (North) dimension and the rest can be found be saying "Never Eat Soggy Waffles". Now, CSS also has built in pattern recognizers. For instance look at the following code that only seems to cover the padding for the top and right of ".object".<br />
<div class="codeblock"><code>.object {<br />    padding: 10px 25px;<br />}</code></div><br />
So what is the padding for the left and bottom of ".object"? Well, it is 10pixels on the bottom and 25pixels on the left. The computer automatically assumes that if you don't enter all the dimensions it should just keep repeating the pattern to fill in the remaining spaces. So to the computer, the above code would look like this:<br />
<div class="codeblock"><code>.object {<br />    padding: 10px 25px (10px 25px);<br />}</code></div><br />
Just like you can type the first three values of a HEX number "color: #fff;" (white) and the computer will recognize it as the full 6 digit HEX number "color: #ffffff;" (white) - you can also type "padding: 5px 10px;" and the computer will see it as "padding: 5px 10px 5px 10px;". The computer will even read just one value and fill all remaining values with that number!<br />
<div class="codeblock"><code>.object {<br />    padding: 10px;<br />}<br />Would mean this to the computer:<br />.object {<br />    padding: 10px (10px 10px 10px);<br />}</code></div></p>
<p>So, hopefully you can use this tutorial to help you better follow the code of CSS champs. :)</p>
    ]]></content>
  </entry>
  <entry>
    <title>Instant HTML Help</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/warpnacelle/instant_html_help" />
    <id>http://www.code2design.com/warpnacelle/instant_html_help</id>
    <published>2007-04-14T01:19:41-04:00</published>
    <updated>2007-04-14T01:19:41-04:00</updated>
    <author>
      <name>WarpNacelle</name>
    </author>
    <category term="HTML" />
    <category term="Tools" />
    <summary type="html"><![CDATA[<p>If you're just learning how to create your own little space in the vast expanse of the World Wide Web you are starting at a great time.<br />
When I began learning, nearly 10 years ago, I had to crack open the books, fire up Wordpad and figure this stuff out by trial and error.  If I needed help, it was a long search through various indexes.<br />
Now, there are so many resources on the web that anyone wanting to learn HTML or any of the vast languages out there, they have gold readily available at the click of a mouse.  Plus, with Web 2.0 becoming more and more prevalent, instant examples are here.<br />
Case in point is the HTML Playground: <a href="http://htmlplayground.com/"><a href="http://htmlplayground.com/">http://htmlplayground.com/</a></a><br />
The name says it all.  A list of web coding tags are available for you to select and have instant examples and sample code to look at and then edit it and see what happens.<br />
This is a fantastic resource for any beginner and one I highly recommend checking out and, well, playing around with!</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>If you're just learning how to create your own little space in the vast expanse of the World Wide Web you are starting at a great time.</p>
<p>When I began learning, nearly 10 years ago, I had to crack open the books, fire up Wordpad and figure this stuff out by trial and error.  If I needed help, it was a long search through various indexes.</p>
<p>Now, there are so many resources on the web that anyone wanting to learn HTML or any of the vast languages out there, they have gold readily available at the click of a mouse.  Plus, with Web 2.0 becoming more and more prevalent, instant examples are here.</p>
<p>Case in point is the HTML Playground: <a href="http://htmlplayground.com/">http://htmlplayground.com/</a></p>
<p>The name says it all.  A list of web coding tags are available for you to select and have instant examples and sample code to look at and then edit it and see what happens.</p>
<p>This is a fantastic resource for any beginner and one I highly recommend checking out and, well, playing around with!</p>
    ]]></content>
  </entry>
  <entry>
    <title>You Can CMS Without One Two</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/maspick/you_can_cms_without_one_two" />
    <id>http://www.code2design.com/maspick/you_can_cms_without_one_two</id>
    <published>2007-04-05T16:07:03-04:00</published>
    <updated>2007-04-05T16:17:50-04:00</updated>
    <author>
      <name>maspick</name>
    </author>
    <category term="Maspick" />
    <category term="PHP" />
    <summary type="html"><![CDATA[<p>In my last posting, I demonstrated how to create a header and footer file to be included at the top and bottom of all, or at least many, pages.  This makes it easy to modify those parts and have the changes automatically spread across all the pages that share that header and footer file.  This is one of the things a CMS simplifies for the user.<br />
But what if part of your header, or footer, file is your navigation system and you want the button or link to change when the page associated is chosen?  That means your header, or footer, must change depending on what page it's included on.  Actually, that's one of the beautiful things about PHP - since it's commands are processed prior to the display of the page, you can program those changes to happen for you automatically.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>In my last posting, I demonstrated how to create a header and footer file to be included at the top and bottom of all, or at least many, pages.  This makes it easy to modify those parts and have the changes automatically spread across all the pages that share that header and footer file.  This is one of the things a CMS simplifies for the user.</p>
<p>But what if part of your header, or footer, file is your navigation system and you want the button or link to change when the page associated is chosen?  That means your header, or footer, must <span style="font-style:italic">change</span> depending on what page it's included on.  Actually, that's one of the beautiful things about PHP - since it's commands are processed prior to the display of the page, you can <span style="font-style:italic">program</span> those changes to happen for you automatically.</p>
<p>The first thing we need to do is determine what page is being displayed at the moment.  The following bit of code, placed at the top of your header file so that it's executed first, will get you the page you're on:</p>
<p><div class="codeblock"><code><font color="#000000"><font color="#0000BB">&lt;?php<br />$parts&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">explode</font><font color="#007700">(</font><font color="#DD0000">'/'</font><font color="#007700">,&nbsp;</font><font color="#0000BB">$_SERVER</font><font color="#007700">[</font><font color="#DD0000">'PHP_SELF'</font><font color="#007700">]);<br /></font><font color="#0000BB">$this&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">$parts</font><font color="#007700">[</font><font color="#0000BB">count</font><font color="#007700">(</font><font color="#0000BB">$parts</font><font color="#007700">)&nbsp;-&nbsp;</font><font color="#0000BB">1</font><font color="#007700">];<br /></font><font color="#0000BB">$pname&nbsp;</font><font color="#007700">=&nbsp;</font><font color="#0000BB">substr</font><font color="#007700">(</font><font color="#0000BB">$this</font><font color="#007700">,&nbsp;</font><font color="#0000BB">0</font><font color="#007700">,&nbsp;-</font><font color="#0000BB">4</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font></font></code></div></p>
<p>What this does is isolate the filename part of the path from the subdirectory(ies) it resides in.  The first command creates an array called parts from whatever is between the slashes ('/') of the path.  The next determines the filename &amp; extension based upon the index value of the last array element.  Finally, we pull off the extension in the third command.  The second and third commands could be combined, but there's a reason I keep them separate that I'll explain in a bit.</p>
<p>Okay, we have the name of the page at our disposal, what do we do with it?  In our navigation, we can now make decisions about what to do when a certain page is loaded.  Here's an example of one navigation element:</p>
<p><div class="codeblock"><code>&lt;div id=&quot;navigation&quot;&gt;<br />&lt;ul&gt;<br />&lt;li<font color="#000000"><font color="#0000BB">&lt;?php&nbsp;</font><font color="#007700">if&nbsp;(</font><font color="#0000BB">$pname&nbsp;</font><font color="#007700">==&nbsp;</font><font color="#DD0000">'guestbook'</font><font color="#007700">)&nbsp;echo&nbsp;</font><font color="#DD0000">"&nbsp;class=\"there\""</font><font color="#007700">;&nbsp;</font><font color="#0000BB">?&gt;</font></font>&gt;<font color="#000000"><font color="#0000BB">&lt;?php&nbsp;</font><font color="#007700">if&nbsp;(</font><font color="#0000BB">$pname&nbsp;</font><font color="#007700">!=&nbsp;</font><font color="#DD0000">'guestbook'</font><font color="#007700">)&nbsp;{&nbsp;</font><font color="#0000BB">?&gt;</font></font>&lt;a href=&quot;guestbook.php&quot;&gt;<font color="#000000"><font color="#0000BB">&lt;?php&nbsp;</font><font color="#007700">}&nbsp;</font><font color="#0000BB">?&gt;</font></font>Guestbook<font color="#000000"><font color="#0000BB">&lt;?php&nbsp;</font><font color="#007700">if&nbsp;(</font><font color="#0000BB">$pname&nbsp;</font><font color="#007700">!=&nbsp;</font><font color="#DD0000">'guestbook'</font><font color="#007700">)&nbsp;echo&nbsp;</font><font color="#DD0000">"&lt;/a&gt;"</font><font color="#007700">;&nbsp;</font><font color="#0000BB">?&gt;</font></font>&lt;/li&gt;</code></div></p>
<p>Here's what's happening in this list item.  Before we close the LI tag, we check to see if the page name (<span style="font-style:italic">$pname</span>) matches the page this item links to.  If it does, we add the class named <span style="font-style:italic">there</span> which will invoke different styling for that item to indicate on the item itself we're on that page. What follows is a determination whether or not we need to make this item a link based upon whether the page is loaded or not.</p>
<p>Looks like a lot of typing, but if you have a means of saving blocks of code that you use frequently, you can save off one of these lines and copy it to your header or footer the number of times to match the number of navigation elements you have.  Now you'll have an automatically changing navigation system that'll reflect what page you're on without having to remember to code it on the page itself.  And since it's located in one easy-to-edit place, you can modify it as needed when changes happen to your site and it will be reflected in all the pages.</p>
<p>Another feature I usually add to the footer of pages is the last modified date.  With information we grabbed in the header and the following code, it will automatically be changed as we update a page.</p>
<p><code>page last modified <font color="#000000"><font color="#0000BB">&lt;?php&nbsp;</font><font color="#007700">echo&nbsp;</font><font color="#0000BB">date</font><font color="#007700">(</font><font color="#DD0000">"m/j/y&nbsp;h:i"</font><font color="#007700">,&nbsp;</font><font color="#0000BB">filemtime</font><font color="#007700">(</font><font color="#0000BB">$this</font><font color="#007700">));&nbsp;</font><font color="#0000BB">?&gt;</font></font></code></p>
<p>This prints the modified date of the filename (<span style="font-style:italic">$this</span>), giving the date and time that is stored for that page.  Nothing earth-shattering, but a handy thing that some visitors look at to determine how old the information is on a particular page.</p>
<p>Next time, we'll explore some more ways to employ PHP to make your static <span style="font-style:italic">CMS</span> a little less static seeming.  Till then, happy coding! :^{&gt;</p>
    ]]></content>
  </entry>
  <entry>
    <title>Photoshop Motion Zoom</title>
    <link rel="alternate" type="text/html" href="http://www.code2design.com/tutorial/photoshop_motion_zoom" />
    <id>http://www.code2design.com/tutorial/photoshop_motion_zoom</id>
    <published>2007-04-01T00:20:28-04:00</published>
    <updated>2007-04-17T23:19:35-04:00</updated>
    <author>
      <name>WarpNacelle</name>
    </author>
    <category term="Motion Zoom" />
    <summary type="html"><![CDATA[<p>I've been absent from this site for a while, so I thought I'd jump back in with a simple yet effective Photoshop tutorial.<br />
This tutorial assumes you know how to create a basic selection and understand layers - but that's really it.  I will be using Photoshop CS2 on Windows XP.<br />
I call this effect, for lack of a better term, a "motion zoom".  This effect adds a blur that creates a zoom focused on a selected item in a picture.<br />
I have attached the photo I will be using called "skateboard.jpg".  I find that the best pictures for this effect are ones with a busy background.  Solid colors or plain backgrounds limit the effect.<br />
So, open up "skateboard.jpg" into Photoshop.<br />
-- Double click on the layer called "Background" to make it available to edit. I renamed it to "Zoom Background".  You may do so if you wish.<br />
-- Next, select your "lasso" tool (L) and select around the skateboarder like so:</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>I've been absent from this site for a while, so I thought I'd jump back in with a simple yet effective Photoshop tutorial.</p>
<p>This tutorial assumes you know how to create a basic selection and understand layers - but that's really it.  I will be using Photoshop CS2 on Windows XP.</p>
<p>I call this effect, for lack of a better term, a "motion zoom".  This effect adds a blur that creates a zoom focused on a selected item in a picture.</p>
<p>I have attached the photo I will be using called "skateboard.jpg".  I find that the best pictures for this effect are ones with a busy background.  Solid colors or plain backgrounds limit the effect.</p>
<p>So, open up "skateboard.jpg" into Photoshop.</p>
<p>-- Double click on the layer called "Background" to make it available to edit. I renamed it to "Zoom Background".  You may do so if you wish.</p>
<p>-- Next, select your "lasso" tool (L) and select around the skateboarder like so:</p>
<p><img src="http://www.morriswebsite.com/ss/sshot1.jpg" alt="" class="bb-image" /></p>
<p>-- Now we will prepare the image for the effect.</p>
<p>-- We need to stick Mr. Selection onto its own layer.  So go to your menu bar and select: LAYER -&gt; NEW -&gt; LAYER VIA COPY (or use the keyboard shortcut: CTRL + J)</p>
<p>You will now have two layers.  Your selection by itself and the original image:</p>
<p><img src="http://www.morriswebsite.com/ss/sshot2.jpg" alt="" class="bb-image" /></p>
<p>-- Now we apply the cool effect.  Click on the bottom layer ("Zoom Background") to select it, go up to your menu bar and select: FILTER -&gt; BLUR -&gt; RADIAL BLUR.</p>
<p>-- Make your blur settings identical to the image below:</p>
<p><img src="http://www.morriswebsite.com/ss/sshot3.jpg" alt="" class="bb-image" /></p>
<ul>
</li><li>Amount: 70
</li><li>Blur Method: Zoom
</li><li>Quality: Good
</ul>
<p>* Note: You can click in the "Blur Center" window and move the center of the zoom around.  This can be used if you decide to use a picture where your selected part is in a corner or something like that.</p>
<p>-- Click "OK" and you now see the skateboarder framed in a very cool looking zoom.</p>
<p>-- We are going to fine tune it a bit.  Select your blur tool - the icon that looks like a water drop - or hit the "R" key.  (If you don't see it, click and hold your mouse over the highlighted tool - after hitting R - and you will see it pop up as a sub-menu choice.</p>
<p>-- Select the top layer (Layer 1) and make sure your blur brush is a small size.  To adjust this on the fly hit your bracket keys: "[" or "]".</p>
<p>-- Blur the outside edge of the skateboarder and he will blend into the zoom layer very smoothly.</p>
<p>-- Your finished product should look something like this (I cropped mine a bit for effect):</p>
<p><img src="http://www.morriswebsite.com/ss/skateboard_final.jpg" alt="" class="bb-image" /></p>
<p>* If you want, select the bottom layer and play around with it to increase the effect.  You can de-saturate it so the skateboarder pops out in color, or mess with the colors to give it a psychedelic look.</p>
<p>And that's it.  A simple yet effective effect!</p>
    ]]></content>
  </entry>
</feed>
<!-- Rendered in 0.6951 -->