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

<channel>
	<title>tmtbox &#187; examples</title>
	<atom:link href="http://www.tmtbox.com/tag/examples/feed" rel="self" type="application/rss+xml" />
	<link>http://www.tmtbox.com</link>
	<description>technology media and telecomm</description>
	<lastBuildDate>Sun, 01 Jan 2012 17:38:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>32 Examples of Websites with a Brave colour Scheme</title>
		<link>http://www.tmtbox.com/32-examples-of-websites-with-a-brave-colour-scheme</link>
		<comments>http://www.tmtbox.com/32-examples-of-websites-with-a-brave-colour-scheme#comments</comments>
		<pubDate>Tue, 24 Feb 2009 05:02:34 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[internet]]></category>
		<category><![CDATA[resource]]></category>
		<category><![CDATA[web2.0]]></category>
		<category><![CDATA[Brave]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[Scheme]]></category>
		<category><![CDATA[Websites]]></category>

		<guid isPermaLink="false">http://www.tmtbox.com/?p=675</guid>
		<description><![CDATA[One key element in the design of any website is colour. Here are some great inspirational websites which show that colour can be used in very extraordinary ways. 1. Design Disease Design Disease Yeah we’ve all seen blue before, but this is beautiful. 2. Macalicious The deep purple/blue work so well together. 3. Breeze Chocolate, [...]]]></description>
			<content:encoded><![CDATA[<div class="entry">
<p>One key element in the design of any website is <strong>colour</strong>. Here  are some great <strong>inspirational websites</strong> which show that colour  can be used in very extraordinary ways.</p>
<h4>1. Design Disease</h4>
<div id="attachment_6366" class="wp-caption alignnone" style="width: 500px;"><a rel="http://designdisease.com/" href="http://designdisease.com/" target="_blank"><img class="size-full wp-image-6366" title="Design Disease" src="http://www.arthack.org/wp-content/uploads/2009/02/colour_1.jpg" alt="colour_1" width="490" height="230" /></a></p>
<p class="wp-caption-text">Design Disease</p>
</div>
<p>Yeah we’ve all seen blue before, but this is beautiful.</p>
<h4>2. Macalicious</h4>
<p>The deep purple/blue work so well together.</p>
<p><a href="http://www.macalicious.com/"><img class="alignnone size-full wp-image-351" style="border-width: 0px;" title="Macalicious | Inspiration Brave Use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_2.jpg" alt="Macalicious | Inspiration Brave Use of Colour" width="490" height="230" /></a></p>
<h4>3. Breeze</h4>
<p>Chocolate, mint and vibrant blue, sounds odd but looks stunning.</p>
<p><a href="http://breezelegalsolutions.com/"><img class="size-full wp-image-352" style="border-width: 0px;" title="Breeze | Inspiration Brave Use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_3.jpg" alt="Breeze | Inspiration Brave Use of Colour" width="490" height="230" /></a></p>
<h4>4. Radu Ceuca</h4>
<p>A wide variety of some very vibrant colours and some dark elements.</p>
<p><a href="http://blog.raduceuca.com/"><img class="size-full wp-image-353" style="border-width: 0px;" title="Radu Ceuca | Inspiration Brave Use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_4.jpg" alt="Radu Ceuca | Inspiration Brave Use of Colour" width="490" height="230" /></a></p>
<h4>5. Nimbupani Designs</h4>
<p>Very vibrant colours, but they go together amazingly well.</p>
<p><a href="http://nimbupani.com/"><img class="size-full wp-image-354" style="border-width: 0px;" title="Nimbupani | Inspiration Brave use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_5.jpg" alt="Nimbupani | Inspiration Brave use of Colour" width="490" height="230" /></a></p>
<h4>6. Catch</h4>
<p>This uses dark boxes to overlay some striking colours. *Video Background</p>
<p><a href="http://www.catchdigital.com/"><img class="size-full wp-image-355" style="border-width: 0px;" title="Catch Digital | Inspiration Brave use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_6.jpg" alt="Catch Digital | Inspiration Brave use of Colour" width="490" height="230" /><br />
</a></p>
<h4>7. Edmonton Recycles</h4>
<p>Using only a few colours can be used to great effect.</p>
<p><a href="http://edmontonrecycling.info/"><img class="size-full wp-image-356" style="border-width: 0px;" title="Edomton Recycles | Inspiration Brave use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_7.jpg" alt="Edomton Recycles | Inspiration Brave use of Colour" width="490" height="230" /></a></p>
<h4>8. Light CMS</h4>
<p>Another great example of using strong colours in the background</p>
<p><a href="http://www.speaklight.com/"><img class="size-full wp-image-357" style="border-width: 0px;" title="Light CMS | Inspiration Brave use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_8.jpg" alt="Light CMS | Inspiration Brave use of Colour" width="490" height="230" /></a></p>
<h4>9. Drew Wilson</h4>
<p>Dark background with some colour blended in, to highlight the name,  smart.</p>
<p><a href="http://www.drewwilson.com/"><img class="size-full wp-image-358" style="border-width: 0px;" title="Drew Wilson | Inspiration Brave use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_9.jpg" alt="Drew Wilson | Inspiration Brave use of Colour" width="490" height="230" /><br />
</a></p>
<h4>10. ADCapital Industries</h4>
<p>Another great example of blending in some background colour to draw focus</p>
<p><a href="http://www.adcapitalindustries.com/"><img class="alignnone size-full wp-image-359" style="border-width: 0px;" title="AD Capital Industries | Inspiration Brave use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_10.jpg" alt="AD Capital Industries | Inspiration Brave use of Colour" width="490" height="230" /></a><a href="http://www.drewwilson.com/"> </a></p>
<h4>11. Sarah Hyland</h4>
<p>That’s right, I’m a bloke, and I think this pink background is “cool”</p>
<p><a href="http://www.sarahhyland.com/"><img class="alignnone size-full wp-image-360" style="border-width: 0px;" title="Sarah Hyland | Inspiration Brave use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_11.jpg" alt="Sarah Hyland | Inspiration Brave use of Colour" width="490" height="230" /></a></p>
<h4>12. DarkMotion</h4>
<p>Vibrant and playful colours, to match a vibrant and playful artist</p>
<p><a href="http://darkmotion.com/"><img class="alignnone size-full wp-image-361" style="border-width: 0px;" title="Dark Motion | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_12.jpg" alt="Dark Motion | Inspiration Brave use of Colours" width="490" height="230" /><br />
</a></p>
<h4>13. Dominum</h4>
<p>Great background and the brave blue &amp; orange details are sweet</p>
<p><a href="http://www.dominum.eu/"><img class="size-full wp-image-362" style="border-width: 0px;" title="Dominum | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_13.jpg" alt="Dominum | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>14. Refresh the Triangle</h4>
<p>I think the colours and theme fit the name so well, they are refreshing  colours</p>
<p><a href="http://refreshthetriangle.org/"><img class="size-full wp-image-363" style="border-width: 0px;" title="Refresh the Triangle | Inspiration Brave use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_14.jpg" alt="Refresh the Triangle | Inspiration Brave use of Colour" width="490" height="230" /><br />
</a></p>
<h4>15. OKB Studio</h4>
<p>A very bold colour choice, and I love the way it fades into black</p>
<p><a href="http://www.okb.es/"><img class="size-full wp-image-364" style="border-width: 0px;" title="OKB Studio | Inspiration Brave use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_15.jpg" alt="OKB Studio | Inspiration Brave use of Colour" width="490" height="230" /></a></p>
<h4>16. Boxwish</h4>
<p>I love everything about this design, but the colours are my favourite  part</p>
<p><a href="http://boxwish.com/"><img class="alignnone size-full wp-image-365" style="border-width: 0px;" title="Boxwish | Inspiration Brave use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_16.jpg" alt="Boxwish | Inspiration Brave use of Colour" width="490" height="230" /><br />
</a></p>
<h4>17. Superawesome</h4>
<p>Very distinct colours in play here, all work brilliant together</p>
<p><a href="http://sprawsm.com/"><img class="alignnone size-full wp-image-366" style="border-width: 0px;" title="Superawesome | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_17.jpg" alt="Superawesome | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>18. Adaptd</h4>
<p>These bands are a great choice of colour, really adds to the design</p>
<p><a href="http://adaptd.com/"><img class="alignnone size-full wp-image-367" style="border-width: 0px;" title="AdaptD | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_18.jpg" alt="AdaptD | Inspiration Brave use of Colours" width="490" height="230" /><br />
</a></p>
<h4>19. Antiphrasis</h4>
<p>Great use of colours site-wide, but I particularly love the blue to yellow  background!</p>
<p><a href="http://www.antiphrasis.com/"><img class="size-full wp-image-368" style="border-width: 0px;" title="Antiphrasis | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_19.jpg" alt="Antiphrasis | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>20. Brunet Garcia</h4>
<p>Just look at those lovely coloured boxes!</p>
<p><a href="http://www.brunetgarcia.com/"><img class="alignnone size-full wp-image-369" style="border-width: 0px;" title="Brunet Garcia | Inspiration Brave use of Colour" src="http://wefunction.com/wp-content/uploads/2008/07/colour_20.jpg" alt="Brunet Garcia | Inspiration Brave use of Colour" width="490" height="230" /></a><a href="http://adaptd.com/"> </a></p>
<h4>21. myNiteLife</h4>
<p>Great deep colours, one of the most inviting holding pages I’ve seen</p>
<p><a href="http://www.mynitelife.co.uk/"><img class="alignnone size-full wp-image-370" style="border-width: 0px;" title="myNiteLife | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_21.jpg" alt="myNiteLife | Inspiration Brave use of Colours" width="490" height="230" /><br />
</a></p>
<h4>22. Dale Harris</h4>
<p>Interesting colour combination, go really great together</p>
<p><a href="http://www.daleharris.com/"><img class="alignnone size-full wp-image-371" style="border-width: 0px;" title="Dale Harris | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_22.jpg" alt="Dale Harris | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>23. Matt Mullenweg</h4>
<p>Probably one of the most unique use of colour I’ve seen, great style.</p>
<p><a href="http://ma.tt/"><img class="alignnone size-full wp-image-372" style="border-width: 0px;" title="Matt Mullenweg | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_23.jpg" alt="Matt Mullenweg | Inspiration Brave use of Colours" width="490" height="230" /><br />
</a></p>
<h4>24. Studio7Designs</h4>
<p>Combining colour with some brilliant light effects = beautiful.</p>
<p><a href="http://www.studio7designs.com/"><img class="alignnone size-full wp-image-373" style="border-width: 0px;" title="Studio7Designs | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_24.jpg" alt="Studio7Designs | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>25. Color Charge</h4>
<p>A wide range of colours, but they are done very well</p>
<p><a href="http://colorcharge.com/"><img class="alignnone size-full wp-image-374" style="border-width: 0px;" title="Color Charge | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_25.jpg" alt="Color Charge | Inspiration Brave use of Colours" width="490" height="230" /><br />
</a></p>
<h4>26. Ploc Media</h4>
<p>Excellent contrast between the dark and very vibrant blue</p>
<p><a href="http://www.ploc.co.uk/"><img class="size-full wp-image-375" style="border-width: 0px;" title="Ploc Media | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_26.jpg" alt="Ploc Media | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>27. George Li</h4>
<p>Bright pink &amp; yellow never looked so good!</p>
<p><a href="http://www.georgeplus.com/"><img class="size-full wp-image-376" style="border-width: 0px;" title="George Lin | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_27.jpg" alt="George Lin | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>28. WebbliWorld</h4>
<p>I’m sure this isn’t going to be for everyone, but remember it is for kids</p>
<p><a href="http://www.webbliworld.com/"><img class="size-full wp-image-377" style="border-width: 0px;" title="WebbliWorld | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_28.jpg" alt="WebbliWorld | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>29. Sygnus Digita</h4>
<p>Another great example of blending some colour into a dark background</p>
<p><a href="http://www.sygnusdigital.com/"><img class="size-full wp-image-378" style="border-width: 0px;" title="Sygnus Digital | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_29.jpg" alt="Sygnus Digital | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>30. Volll</h4>
<p>More great colours used on an illustrated background</p>
<p><a href="http://www.volll.com/"><img class="alignnone size-full wp-image-379" style="border-width: 0px;" title="Volll | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_30.jpg" alt="Volll | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>31. Grafikas</h4>
<p>Rich, deep and very elegant feel to this site</p>
<p><a href="http://grafikas.com/"><img class="size-full wp-image-380" style="border-width: 0px;" title="Grafikas | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_31.jpg" alt="Grafikas | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>32. Alisa MTV</h4>
<p>Contrast of hot and cold here, and it looks great!</p>
<p><a href="http://alisa.mtv.ru/"><img class="size-full wp-image-381" style="border-width: 0px;" title="Alisa MTV | Inspiration Brave use of Colours" src="http://wefunction.com/wp-content/uploads/2008/07/colour_32.jpg" alt="Alisa MTV | Inspiration Brave use of Colours" width="490" height="230" /></a></p>
<h4>My Thoughts</h4>
<p>I think the main reason behind the post was to show people (and myself) that you can use colour in a more striking way. Far too often I only use colour on certain elements and for things such as links etc. But as you can see from this collection you can get away with using a lot of colour, as long that you give your colour scheme some real thought. (Via DesignDisease)</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tmtbox.com/32-examples-of-websites-with-a-brave-colour-scheme/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>examples of SQLite in Action</title>
		<link>http://www.tmtbox.com/examples-of-sqlite-in-action</link>
		<comments>http://www.tmtbox.com/examples-of-sqlite-in-action#comments</comments>
		<pubDate>Thu, 15 Nov 2007 18:37:55 +0000</pubDate>
		<dc:creator>kevin</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[QLite in Action]]></category>

		<guid isPermaLink="false">http://www.tmtbox.com/archives/examples-of-sqlite-in-action</guid>
		<description><![CDATA[This section steps through some of the basic tasks in working with databases, using the SQLite version of things. Before doing anything, you must create a database: 1. Open a new file in your text editor and start a PHP block: 2. 3. Use the sqlite_open() function to open a database called test.db one level [...]]]></description>
			<content:encoded><![CDATA[<p>This section steps through some of the basic tasks in working with databases, using the SQLite version of things. Before doing anything, you must create a database:</p>
<p>1.    Open a new file in your text editor and start a PHP block:</p>
<p>2. 3. Use the sqlite_open() function to open a database called test.db one level up from the document root—do not worry that it has not been created yet, because this function will create the file if it does not already exist. The sql_error_string() function will display any error message if the command fails:</p>
<p>4.            $db = sqlite_open(&#8220;../test.db&#8221;) or die(sql_error_string());<br />
5.</p>
<p>Note<br />
You might notice that no username or password is used to create or open a SQLite database. This is true, because the SQLite database is technically just a plain file, with no requirements for access other than the capability to read and write to the directory in which you are placing the file.<br />
6.    Close the PHP block:</p>
<p>7.            ?&gt;<br />
Save this file as sqlite1.php and place it in the document root of your web browser. Access the script at http://127.0.0.1/sqlite1.php to create the database.<br />
Note<br />
There will be no output if this script is successful. You will see a message only if the script fails to perform.<br />
Now that you have a working SQLite database, you can move on to creating tables and issuing queries.</p>
<p>Creating a Table and Storing Data with SQLite<br />
When you created tables using MySQL (and in fact when you create a table in any relational database system), you specifically defined the field types and field lengths. For example, you might have had a field called name that was a 25-character varchar field, or a field called start_date that was a datetime field. SQLite is loosely typed, meaning the contents of all fields, regardless of what type they actually are, are stored as strings. Thus, SQLite does not require you to define your fields when you create a table, and if you do, they will be ignored.</p>
<p>In the next example, you will create a table that just holds first names, last names, and e-mail addresses, and populates the table with a few records:</p>
<p>1.    Open a new file in your text editor and start a PHP block:</p>
<p>2.             3.    Use the sqlite_open() function to open the database previously created:</p>
<p>4.            $db = sqlite_open(&#8220;../test.db&#8221;) or die(sql_error_string());<br />
5.    Use the sqlite_query() function to issue a table-creation command:</p>
<p>6.            sqlite_query($db, &#8220;CREATE TABLE my_friends (first_name, last_name,<br />
7.            email)&#8221;);<br />
8.<br />
9.    Use the sqlite_query() function to add a few entries using the SQL INSERT command:</p>
<p>10.        sqlite_query($db, &#8220;INSERT INTO my_friends<br />
11.             VALUES (&#8216;John&#8217;, &#8216;Smith&#8217;, &#8216;john@smith.com&#8217;)&#8221;);<br />
12.        sqlite_query($db, &#8220;INSERT INTO my_friends<br />
13.             VALUES (&#8216;Jane&#8217;, &#8216;Doe&#8217;, &#8216;jane@doe.com&#8217;)&#8221;);<br />
14.        sqlite_query($db, &#8220;INSERT INTO my_friends<br />
15.             VALUES (&#8216;Julie&#8217;, &#8216;Meloni&#8217;, &#8216;julie@thickbook.com&#8217;)&#8221;);<br />
16.Close the PHP block:</p>
<p>17.        ?&gt;<br />
The complete script should look like this:</p>
<p>$db = sqlite_open(&#8220;../test.db&#8221;) or die(sql_error_string());<br />
sqlite_query($db, &#8220;CREATE TABLE my_friends (first_name, last_name, email)&#8221;);<br />
sqlite_query($db, &#8220;INSERT INTO my_friends<br />
VALUES (&#8216;John&#8217;, &#8216;Smith&#8217;, &#8216;john@smith.com&#8217;)&#8221;);<br />
sqlite_query($db, &#8220;INSERT INTO my_friends<br />
VALUES (&#8216;Jane&#8217;, &#8216;Doe&#8217;, &#8216;jane@doe.com&#8217;)&#8221;);<br />
sqlite_query($db, &#8220;INSERT INTO my_friends<br />
VALUES (&#8216;Julie&#8217;, &#8216;Meloni&#8217;, &#8216;julie@thickbook.com&#8217;)&#8221;);<br />
?&gt;<br />
Save this file as sqlite2.php and place it in the document root of your web browser. Access the script at http://127.0.0.1/sqlite2.php to issue these SQLite commands. Again, there will be no output if this script is successful. You will see a message only if the script fails to perform one or more of the commands.</p>
<p>In the next section, you retrieve items from your table.</p>
<p>Retrieving Items with SQLite<br />
Now that you have records in your SQLite table, you can retrieve them. Again, the process is quite similar to retrieving data from a MySQL table.</p>
<p>1.    Open a new file in your text editor and start a PHP block:</p>
<p>2.             3.    Use the sqlite_open() function to open the database you previously created:</p>
<p>4.            $db = sqlite_open(&#8220;../test.db&#8221;) or die(sql_error_string());<br />
5.    Use the sqlite_query() function to issue a SELECT command, intended to retrieve records in ascending order by last name:</p>
<p>6.            $r = sqlite_query($db, &#8220;SELECT * FROM my_friends ORDER BY last_name ASC&#8221;);<br />
7.    Check for a result and print a message if the query was not successful:</p>
<p>8.            if (!$r) {<br />
9.                 echo &#8220;Sorry, no records.&#8221;;<br />
10.        } else {<br />
11.Add a while loop to handle a successful query. This loop will use the sqlite_fetch_array() function, which works just like the ysql_fetch_array() function you used throughout the book:</p>
<p>12.        while ($record = sqlite_fetch_array($r)) {<br />
13.Create variables for each field you&#8217;re pulling from your table:</p>
<p>14.        $first_name = $record[first_name];<br />
15.        $last_name = $record[last_name];<br />
16.        $email = $record[email];<br />
17.Print each record to the screen, and then close the while loop, the if&#8230;else block, and the PHP block:</p>
<p>18.        echo &#8220;record: $last_name, $first_name ($email)<br />
&#8220;;<br />
19.        }<br />
20.        }<br />
21.        ?&gt;<br />
Your entire code should look like this:</p>
<p>$db = sqlite_open(&#8220;../test.db&#8221;) or die(sql_error_string());<br />
$r = sqlite_query($db, &#8220;SELECT * FROM my_friends ORDER BY last_name ASC&#8221;);<br />
if (!$r) {<br />
echo &#8220;Sorry, no records.&#8221;;<br />
} else {<br />
while ($record = sqlite_fetch_array($r)) {<br />
$first_name = $record[first_name];<br />
$last_name = $record[last_name];<br />
$email = $record[email];<br />
echo &#8220;record: $last_name, $first_name ($email)<br />
&#8220;;<br />
}<br />
}<br />
?&gt;<br />
Save this file as sqlite3.php and place it in the document root of your web browser. Access the script at http://127.0.0.1/sqlite3.php to issue these SQLite commands and display the output.</p>
<p>Now that you&#8217;ve seen the process for working with SQLite is procedurally similar to working with other databases, you can glance through the next section to pick up some other tidbits of information.<br />
Performing Other Tasks with SQLite<br />
In the previous sections, you&#8217;ve seen how to create SQLite databases and tables, and insert and select elements into/from these tables. It&#8217;s safe to make the leap that you can issue DELETE and DROP commands similarly to remove records and tables, and you can also use UPDATE to change fields within a record—all of these actions are simply variations on the SQL query that is issued using the sqlite_query() function.</p>
<p>As to the tasks you can perform with SQLite, they&#8217;re the same tasks that you can perform with MySQL; all of the MySQL-based code in this book can be rewritten to use SQLite. However, there are two things the code relied on when using MySQL that haven&#8217;t been covered in this appendix: auto-incrementing fields and date-stamping.</p>
<p>To implement the use of auto-incrementing fields, you simply have to make some changes to the sqlite2.php script:</p>
<p>1.    Open sqlite2.php in your text editor.</p>
<p>2.    Change the table-creation command to:</p>
<p>3.            sqlite_query($db, &#8220;CREATE TABLE my_friends2 (id INTEGER<br />
4.                 PRIMARY KEY, first_name, last_name, email)&#8221;);<br />
5.    Change the record-insertion commands to:</p>
<p>6.            sqlite_query($db, &#8220;INSERT INTO my_friends2 (first_name,<br />
7.                 last_name, email) VALUES (&#8216;John&#8217;, &#8216;Smith&#8217;,<br />
8.                 &#8216;john@smith.com&#8217;)&#8221;);<br />
9.            sqlite_query($db, &#8220;INSERT INTO my_friends2 (first_name,<br />
10.             last_name, email) VALUES (&#8216;Jane&#8217;, &#8216;Doe&#8217;,<br />
11.             &#8216;jane@doe.com&#8217;)&#8221;);<br />
12.        sqlite_query($db, &#8220;INSERT INTO my_friends2 (first_name,<br />
13.             last_name, email) VALUES (&#8216;Julie&#8217;, &#8216;Meloni&#8217;,<br />
14.             &#8216;julie@thickbook.com&#8217;)&#8221;);<br />
Save this file as sqlite4.php and place it in the document root of your web browser. Access the script at http://127.0.0.1/sqlite4.php to issue these SQLite commands. Again, there will be no output if this script is successful. You will see a message only if the script fails to perform one or more of the commands.</p>
<p>To see if this script did the trick, modify the sqlite3.php script to retrieve and print the ID field:</p>
<p>1.    Open sqlite3.php in your text editor.</p>
<p>2.    Change the name of the table in the query:</p>
<p>3.            $r = sqlite_query($db, &#8220;SELECT * FROM my_friends2 ORDER BY last_name ASC&#8221;);<br />
4.    Change the while loop:</p>
<p>5.            while ($record = sqlite_fetch_array($r)) {<br />
6.                 $id = $record[id];<br />
7.                 $first_name = $record[first_name];<br />
8.                 $last_name = $record[last_name];<br />
9.                 $email = $record[email];<br />
10.             echo &#8220;record ID# $id: $last_name, $first_name ($email)<br />
&#8220;;<br />
11.        }<br />
Save this file as sqlite5.php and place it in the document root of your web browser. Access the script at http://127.0.0.1/sqlite5.php to issue these SQLite commands and display the output.<br />
Just like in MySQL, the ID fields are automatically incremented upon record insertion.</p>
<p>Next, let&#8217;s take a look at how to handle date-stamping of records, because there&#8217;s no now() function as there is in MySQL, nor are there particular methods for formatting date-related fields. The solution is simply to store an integer, the output of the PHP time() function. You can then format this stored value any way you want, using PHP, when you retrieve it for display.</p>
<p>The next steps will work again with the same tables and records used in this appendix, just building on the previous steps.</p>
<p>1.    Open sqlite4.php in your text editor.</p>
<p>2.    Change the table-creation command to:</p>
<p>3.            sqlite_query($db, &#8220;CREATE TABLE my_friends3<br />
4.                 (id INTEGER PRIMARY KEY, first_name, last_name, email,<br />
5.                 date_added)&#8221;);<br />
6.    Change the record-insertion commands to:</p>
<p>7.            sqlite_query($db, &#8220;INSERT INTO my_friends3<br />
8.                 (first_name, last_name, email, date_added) VALUES<br />
9.                 (&#8216;John&#8217;, &#8216;Smith&#8217;, &#8216;john@smith.com&#8217;, &#8216;&#8221;.time().&#8221;&#8216;)&#8221;);<br />
10.        sqlite_query($db, &#8220;INSERT INTO my_friends3<br />
11.             (first_name, last_name, email, date_added) VALUES<br />
12.             (&#8216;Jane&#8217;, &#8216;Doe&#8217;, &#8216;jane@doe.com&#8217;, &#8216;&#8221;.time().&#8221;&#8216;)&#8221;);<br />
13.        sqlite_query($db, &#8220;INSERT INTO my_friends3<br />
14.             (first_name, last_name, email, date_added) VALUES<br />
15.             (&#8216;Julie&#8217;, &#8216;Meloni&#8217;, &#8216;julie@thickbook.com&#8217;, &#8216;&#8221;.time().&#8221;&#8216;)&#8221;);<br />
Save this file as sqlite6.php and place it in the document root of your web browser. Access the script at http://127.0.0.1/sqlite6.php to issue these SQLite commands. Again, there will be no output if this script is successful. You will see a message only if the script fails to perform one or more of the commands.</p>
<p>To see if this script did the trick, modify the sqlite5.php script to retrieve, format, and print the values in the date_added field:</p>
<p>1.    Open sqlite5.php in your text editor.</p>
<p>2.    Change the name of the table in the query, and order the records by ID:</p>
<p>3.            $r = sqlite_query($db, &#8220;SELECT * FROM my_friends3 ORDER BY id ASC&#8221;);<br />
4.    Add the following inside the while loop, after the line that defines the value of $email:</p>
<p>5.            $date_added = date(&#8220;l, M d Y, h:i:s A&#8221;, $record[date_added]);<br />
6.<br />
7.</p>
<p>Note<br />
In this example, the date() function formats the value of stored in the date_added field. You can learn more about the numerous formatting options for the date() function in Appendix B, &#8220;Basic PHP Language Reference,&#8221; and in the PHP manual at http://www.php.net/date.<br />
8.    Change the echo statement inside the while loop to:</p>
<p>9.            echo &#8220;record ID# $id: $last_name, $first_name ($email)<br />
10.        added on $date_added<br />
&#8220;;<br />
Save this file as sqlite7.php and place it in the document root of your web browser. Access the script at http://127.0.0.1/sqlite7.php to issue these SQLite commands and display the output. You should see something like this figure, including the formatted version of the date-stamp stored in the SQLite table.<br />
As you can see, virtually anything you can do with MySQL, you can do (with a little elbow grease in some instances) with SQLite. If you find yourself without a database server, nothing should keep you from utilizing this new feature of PHP 5.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tmtbox.com/examples-of-sqlite-in-action/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

