<?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>Simon James Clegg &#187; MySQL</title>
	<atom:link href="http://simonjamesclegg.co.uk/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://simonjamesclegg.co.uk</link>
	<description>Freelance web developer and IT consultant</description>
	<lastBuildDate>Wed, 05 May 2010 06:54:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Sefton court bed and breakfast</title>
		<link>http://simonjamesclegg.co.uk/2009/07/sefton-court-bed-and-breakfast/</link>
		<comments>http://simonjamesclegg.co.uk/2009/07/sefton-court-bed-and-breakfast/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 20:45:28 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Partners]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Recent work]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[availability checker]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[hotel booking system]]></category>
		<category><![CDATA[hotel website]]></category>

		<guid isPermaLink="false">http://simonjamesclegg.co.uk/?p=150</guid>
		<description><![CDATA[SeftonÂ Court is a Michelin approved bed and breakfast in Llandudno, North Wales. David White of Whitekite design, a close working partner of mine, won the contract to redesign the hotel website and he asked me to develop the front-end online booking system with room availability checker together with a back-end booking management application. Having [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-151" href="http://simonjamesclegg.co.uk/2009/07/07/sefton-court-bed-and-breakfast/sefton/"><img class="alignnone size-full wp-image-151" title="sefton" src="http://simonjamesclegg.co.uk/wp-content/uploads/2009/07/sefton.png" alt="" width="496" height="159" /></a></p>
<p><strong>SeftonÂ Court</strong> is a Michelin approved  bed and breakfast in Llandudno, North Wales.</p>
<p>David White of Whitekite design, a close working partner of mine, won the contract to redesign the hotel website and he asked me to develop the front-end <strong>online booking system </strong>with <strong>room availability checker</strong> together with a back-end <strong>booking management</strong> application. Having looked at the option of a Joomla!-based CMS with room booking component I was commissioned in the end to develop an entirely original and bespoke application. We are now very close to launching the site, so please come back shortly to see the results!</p>
<p>This bespoke <strong>online hotel booking managment system</strong> includes:</p>
<ul>
<li>Entirely bespoke fully featured hotel booking management system</li>
<li>Online automated room availability checker</li>
<li>Room reservation application with secure hosting</li>
<li>Encrypted temporary storage of payment details</li>
<li>Hooks up easily to any online payment gateway</li>
<li>Back-end administration for managing rooms, images, descriptions, rates</li>
<li>Back-end booking management for manual override</li>
<li>Automated email notifications</li>
<li>PHP, MySQL, SSL, cryptography</li>
</ul>
<div><a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?pub=&amp;url=http%3A%2F%2Fsimonjamesclegg.co.uk%2F2009%2F07%2Fsefton-court-bed-and-breakfast%2F&amp;title=Sefton+court+bed+and+breakfast', 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no'); return false;" title="Bookmark using any bookmark manager!" target="_blank"><img src="http://s3.addthis.com/button1-bm.gif" width="125" height="16" border="0" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://simonjamesclegg.co.uk/2009/07/sefton-court-bed-and-breakfast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>playpics</title>
		<link>http://simonjamesclegg.co.uk/2009/07/playpics/</link>
		<comments>http://simonjamesclegg.co.uk/2009/07/playpics/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 20:15:57 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Featured Work]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Recent work]]></category>
		<category><![CDATA[Social networking]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[e-Learning]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[Schools]]></category>

		<guid isPermaLink="false">http://simonjamesclegg.co.uk/?p=146</guid>
		<description><![CDATA[playpics is a new subscription website for teachers. This new educational resource offers a large library of original images designed specially to support the primary school curriculum. The basis of this project involves a lot of image manipulation and database development while the later phases are to feature more web 2.0 online community functionality. As [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-147" href="http://simonjamesclegg.co.uk/2009/07/playpics/playpics/"></a><a rel="attachment wp-att-147" href="http://simonjamesclegg.co.uk/2009/07/playpics/playpics/"><img class="aligncenter size-full wp-image-147" title="playpics" src="http://simonjamesclegg.co.uk/wp-content/uploads/2009/07/playpics.png" alt="playpics" width="496" height="159" /></a></p>
<p><strong>playpics </strong>is a new subscription website for teachers. This new educational resource offers a large library of original images designed specially to support the primary school curriculum.</p>
<p>The basis of this project involves a lot of image manipulation and database development while the later phases are to feature more web 2.0 online community functionality.</p>
<p>As this is a brand new venture I am unable to give too much away at this stage. But watch this space.</p>
<div><a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?pub=&amp;url=http%3A%2F%2Fsimonjamesclegg.co.uk%2F2009%2F07%2Fplaypics%2F&amp;title=playpics', 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no'); return false;" title="Bookmark using any bookmark manager!" target="_blank"><img src="http://s3.addthis.com/button1-bm.gif" width="125" height="16" border="0" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://simonjamesclegg.co.uk/2009/07/playpics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL to XML with PHP</title>
		<link>http://simonjamesclegg.co.uk/2008/11/mysql-to-xml-with-php/</link>
		<comments>http://simonjamesclegg.co.uk/2008/11/mysql-to-xml-with-php/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 01:59:01 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://simonjamesclegg.co.uk/?p=52</guid>
		<description><![CDATA[This tutorial is based on a bit of code I created to extend Flash Nifties XML slideshow to use an MySQL database as its datasource. It assumes you have a MySQL database where you store your images. [Download sql2xml.zip for XML Slide Show] Step 1: Make the database connection &#60;?php $con = mysql_connect&#40;&#34;localhost&#34;,&#34;username&#34;,&#34;password&#34;&#41;; if &#40;!$con&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial is based on a bit of code I created to extend <a href="http://www.flashnifties.com/xml_slideshow.php">Flash Nifties XML slideshow</a> to use an MySQL database as its datasource.</p>
<p>It assumes you have a MySQL database where you store your images.<br />
[<a href='http://simonjamesclegg.co.uk/wp-content/uploads/2008/11/sql2xml.zip'>Download sql2xml.zip for XML Slide Show</a>]</p>
<p><strong>Step 1: Make the database connection</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$con</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
  <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="">'Could not connect: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Step 2: Query your database</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$database</span><span style="color: #339933;">,</span> <span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$query_images</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM images ORDER BY RAND()&quot;</span>;
<span style="color: #000088;">$images</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query_images</span><span style="color: #339933;">,</span> <span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$row_images</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$images</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>ORDER BY RAND()</strong> &#8211; this randomizes the results of the query.</p>
<p><strong>Step 3: Generate the XML markup</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//start the xml dataset</span>
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="">'&lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?&gt;
	&lt;slideshow&gt;
	 '</span>;
&nbsp;
		<span style="color: #666666; font-style: italic;">// create a loop that outputs each row from the sql query</span>
&nbsp;
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row_images</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$images</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$xml</span> <span style="color: #339933;">.=</span><span style="">'	&lt;image img=&quot;images/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$row_images</span><span style="color: #009900;">&#91;</span><span style="">'image_file'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="">'&quot; /&gt;
					'</span>;
&nbsp;
		<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//close the xml dataset</span>
<span style="color: #000088;">$xml</span> <span style="color: #339933;">.=</span><span style="">'&lt;/slideshow&gt;'</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Step 4: Write the output to file</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="">'slideshow.xml'</span><span style="color: #339933;">,</span> <span style="">'w'</span><span style="color: #009900;">&#41;</span>;
<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #339933;">,</span> <span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span>;
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This will look for the file slideshow.xml and will overwrite its contents with the output above. If the fiels does not exist it will attempt to create it.</p>
<p><strong>The result &#8211; slideshow.xml</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;iso-8859-1&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;slideshow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">img</span>=<span style="color: #ff0000;">&quot;images/image2.jpg /&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">img</span>=<span style="color: #ff0000;">&quot;images/image5.jpg /&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">img</span>=<span style="color: #ff0000;">&quot;images/image1.jpg /&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">img</span>=<span style="color: #ff0000;">&quot;images/image3.jpg /&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">img</span>=<span style="color: #ff0000;">&quot;images/image7.jpg /&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">img</span>=<span style="color: #ff0000;">&quot;images/image4jpg /&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image</span> <span style="color: #000066;">img</span>=<span style="color: #ff0000;">&quot;images/image6.jpg /&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/slideshow<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And there you have your dataset ready for consumption by your application.</p>
<p>In order to use this to technique to extend the <a href="http://www.flashnifties.com/xml_slideshow.php">Flash Nifties XML</a> Slideshow simply <a href='http://simonjamesclegg.co.uk/wp-content/uploads/2008/11/sql2xml.zip'> download sql2xml.zip</a> and follow the instructions contained within.</p>
<p>You can see an example of the databse-driven XML Flash Slideshow at <a href="http://st-andrewsprimary.co.uk">St Andrew&#8217;s Primary School website</a></p>
<div><a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?pub=&amp;url=http%3A%2F%2Fsimonjamesclegg.co.uk%2F2008%2F11%2Fmysql-to-xml-with-php%2F&amp;title=MySQL+to+XML+with+PHP', 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no'); return false;" title="Bookmark using any bookmark manager!" target="_blank"><img src="http://s3.addthis.com/button1-bm.gif" width="125" height="16" border="0" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://simonjamesclegg.co.uk/2008/11/mysql-to-xml-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP, MySQL and Japanese characters</title>
		<link>http://simonjamesclegg.co.uk/2008/11/displaying-japanese-characters-with-php-from-mysql-data-source/</link>
		<comments>http://simonjamesclegg.co.uk/2008/11/displaying-japanese-characters-with-php-from-mysql-data-source/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 16:58:11 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://simonjamesclegg.co.uk/2008/11/16/displaying-japanese-characters-with-php-from-mysql-data-source/</guid>
		<description><![CDATA[I recently set up a photoblog for my wife. As Junko is Japanese she wanted the ability to write posts in her mother tongue. WordPress handles this perfectly well out of the box but when I came to interrogating the WordPress database to display the latest blog titles on an external page I was just [...]]]></description>
			<content:encoded><![CDATA[<p>I recently set up a <a href="http://chonanclegg.co.uk/photography" title="Junko's photo blog">photoblog</a> for my wife. As Junko is Japanese she wanted the ability to write posts in her mother tongue. WordPress handles this perfectly well out of the box but when I came to interrogating the WordPress database to display the latest blog titles on an <a href="http://chonanclegg.co.uk">external page</a> I was just getting ????. The character encoding of the page was set to utf8 and the collation of the MySQL database and all it&#8217;s tables was also set to utf8_unicode_generals so I was baffled.</p>
<p>I disovered that the reason this was happening is because the default encoding of a php-MySQL connection is utf8. So the solution turns out to be very simple: set the econding for the query session to utf8 with the query: <strong>mysql_query(&#8220;SET NAMES &#8216;utf8&#8242;&#8221;, $connection); </strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$database</span><span style="color: #339933;">,</span> <span style="color: #000088;">$connection</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SET NAMES 'utf8'&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$connection</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM table &quot;</span>;
&nbsp;
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$connection</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connection</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<p>If you are using PHP 5.2 or later you need to use instead:</p>
<p><strong>mysql_set_charset(&#8216;utf8&#8242;,$connection); </strong><strong><br />
</strong></p>
<div><a href="http://www.addthis.com/bookmark.php" onclick="window.open('http://www.addthis.com/bookmark.php?pub=&amp;url=http%3A%2F%2Fsimonjamesclegg.co.uk%2F2008%2F11%2Fdisplaying-japanese-characters-with-php-from-mysql-data-source%2F&amp;title=PHP%2C+MySQL+and+Japanese+characters', 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no'); return false;" title="Bookmark using any bookmark manager!" target="_blank"><img src="http://s3.addthis.com/button1-bm.gif" width="125" height="16" border="0" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://simonjamesclegg.co.uk/2008/11/displaying-japanese-characters-with-php-from-mysql-data-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

