<?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>Bright Cherry</title>
	<atom:link href="http://www.brightcherry.co.uk/scribbles/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brightcherry.co.uk/scribbles</link>
	<description></description>
	<lastBuildDate>Fri, 27 Aug 2010 18:00:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Ajax JQuery &#8211; Rotating Image Script</title>
		<link>http://www.brightcherry.co.uk/scribbles/2010/08/27/ajax-jquery-rotating-image-script/</link>
		<comments>http://www.brightcherry.co.uk/scribbles/2010/08/27/ajax-jquery-rotating-image-script/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 18:00:38 +0000</pubDate>
		<dc:creator>Maruf</dc:creator>
				<category><![CDATA[Ajax]]></category>

		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=241</guid>
		<description><![CDATA[I can&#8217;t remember for the life of me where I got this code from, but if I could, I&#8217;d give the author the credit. I didn&#8217;t write this code, but it&#8217;s something I wanted to share because it&#8217;s pretty cool. There are HUNDREDS of image rotating scripts out there, but I like this one in [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t remember for the life of me where I got this code from, but if I could, I&#8217;d give the author the credit. I didn&#8217;t write this code, but it&#8217;s something I wanted to share because it&#8217;s pretty cool.</p>
<p>There are HUNDREDS of image rotating scripts out there, but I like this one in particular because the code is light and it&#8217;s a lot smoother than a lot I&#8217;ve seen. Additionally, unlike a lot of the examples out there, this method doesn&#8217;t require a heavy jQuery extension. This is pure JQuery (and a tiny bit of CSS).</p>
<h4>Here&#8217;s an example of what this code will do:</h4>
<p><iframe src ="http://www.brightcherry.co.uk/code_examples/jquery-image-rotate/index.html" width="300" height="300" frameborder="0" scrolling="no"></p>
<p>Your browser does not support iframes.</p>
<p></iframe></p>
<h4>Here&#8217;s the code:</h4>

<div class="wp_codebox_msgheader"><span class="right"><sup></sup></span><span class="left"><a rel="nofollow" href="javascript:;" onclick="javascript:showCodeTxt('p241code2'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2412"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
</pre></td><td class="code" id="p241code2"><pre class="html" style="font-family:monospace;">/*** set the width and height to match your images **/
&nbsp;
#slideshow {
	position:relative;
	height:330px;
}
&nbsp;
#slideshow img {
	position:absolute;
	top:0;
	left:0;
	z-index:8;
	opacity:0.0;
}
&nbsp;
#slideshow img.active {
	z-index:10;
	opacity:1.0;
}
&nbsp;
#slideshow img.last-active {
	z-index:9;
}
&nbsp;
&lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt; 
function slideSwitch() {
var $active = $('#slideshow .active');
if ( $active.length == 0 ) $active = $('#slideshow img:last');
	var $next =  $active.next().length ? $active.next()
	: $('#slideshow img:first');
&nbsp;
	$active.addClass('last-active');
&nbsp;
	$next.css({opacity: 0.0})
		.addClass('active')
    //adjust value to change the time taken to fade between images
		.animate({opacity: 1.0}, 3000, function() {
		$active.removeClass('active last-active');
	});
}
&nbsp;
$(function() {
    //adjust value to change the interval between each image change
		setInterval( &quot;slideSwitch()&quot;, 4000 );
});
&lt;/script&gt;  
&nbsp;
&lt;div id=&quot;slideshow&quot;&gt;
  &lt;!-- the active class is for the image you want to show on page load --&gt; 
	&lt;img src=&quot;images/rotate/1.jpg&quot; class=&quot;active&quot; alt=&quot;&quot; title=&quot;&quot; /&gt; 
	&lt;img src=&quot;images/rotate/2.jpg&quot; alt=&quot;&quot; title=&quot;&quot; /&gt; 
	&lt;img src=&quot;images/rotate/3.jpg&quot; alt=&quot;&quot; title=&quot;&quot; /&gt; 
&lt;/div&gt;</pre></td></tr></table></div>

<h4>Download</h4>
<p><a href="http://www.brightcherry.co.uk/downloads/jquery-image-rotate.zip" rel="nofollow" target="new" title="Download JQuery Rotating Image Script">Download JQuery Rotating Image Script</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.brightcherry.co.uk/scribbles/2010/08/27/ajax-jquery-rotating-image-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Capitalize First Letter Of Every Sentence For Proper Formatting</title>
		<link>http://www.brightcherry.co.uk/scribbles/2010/07/31/php-capitalize-first-letter-of-every-sentence/</link>
		<comments>http://www.brightcherry.co.uk/scribbles/2010/07/31/php-capitalize-first-letter-of-every-sentence/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 08:45:54 +0000</pubDate>
		<dc:creator>Maruf</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=233</guid>
		<description><![CDATA[Here&#8217;s an extremely useful snippet of code that will properly format sentences with capitalization. Actually, what the code really does is capitialize every letter AFTER a full-stop (period). Here&#8217;s an example of what the code will do&#8230; Before: Hello This Is An Example Of A Sentence Which Has Odd Capitalization Which You May Want Fixing. [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an extremely useful snippet of code that will properly format sentences with capitalization. Actually, what the code really does is capitialize every letter AFTER a full-stop (period). Here&#8217;s an example of what the code will do&#8230;</p>
<h4>Before:</h4>
<blockquote><p>
Hello This Is An Example Of A Sentence Which Has Odd Capitalization Which You May Want Fixing. tHere Are Problems With This Method, Which I Will disclose Shortly. If You Know How To Improve THis Code Please Let Me Know.
</p></blockquote>
<h4>After:</h4>
<blockquote><p>
Hello this is an example of a sentence which has odd capitalization which you may want fixing. There are problems with this method, which i will disclose shortly. If you know how to improve this code please let me know.
</p></blockquote>

<div class="wp_codebox_msgheader"><span class="right"><sup></sup></span><span class="left"><a rel="nofollow" href="javascript:;" onclick="javascript:showCodeTxt('p233code5'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2335"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p233code5"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//define string</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hello This Is An Example Of A Sentence Which Has Odd Capitalization Which You May Want Fixing. tHere Are Problems With This Method, Which I Will disclose Shortly. If You Know How To Improve THis Code Please Let Me Know.&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//first we make everything lowercase, and then make the first letter if the entire string capitalized</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ucfirst</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//now we run the function to capitalize every letter AFTER a full-stop (period).</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace_callback</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[.!?].*?\w/'</span><span style="color: #339933;">,</span> <span style="color: #990000;">create_function</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'$matches'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'return strtoupper($matches[0]);'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//print the result</span>
<span style="color: #990000;">echo</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>There you have it. But there are flaws with this code, which you should be aware of.</p>
<h4>Recognised problems to consider</h4>
<p>This code will only capitalize the first letter of the string and all letters after full-stops (periods). Names, acronyms and countries will become lowercase when they should be capitalized.</p>
<p>Acronyms with full-stops won&#8217;t return as they should appear. For example, &#8220;e.g.&#8221; will return as &#8220;e.G.&#8221; because the G is directly after a full-stop.</p>
<p>A common problem is the word &#8220;I&#8221;, it will be returned in lowercase. For example, &#8220;You and i may have to make some exceptions&#8221;</p>
<h5>Solutions</h5>
<p>The way I overcome these issues by making rules with the str_replace function. Put these exceptions after the function has run and before printing the results. This isn&#8217;t an ideal solution for large lumps of data as there would be a lot of exceptions, but it&#8217;s useful for a manageable data size. You could, however, create your own function(s) to make the clean up process quicker and easier to handle large data.</p>
<h4>Possible solutions</h4>

<div class="wp_codebox_msgheader"><span class="right"><sup></sup></span><span class="left"><a rel="nofollow" href="javascript:;" onclick="javascript:showCodeTxt('p233code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2336"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p233code6"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">//to overcome the e.G. problem</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;e.G.&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;e.g.&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//to overcome the lowercase i problem</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; i &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot; I &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//to overcome the acronym problem</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;dps&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;DPS&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Does anyone have any better solutions, or perhaps even improvements to the existing code?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brightcherry.co.uk/scribbles/2010/07/31/php-capitalize-first-letter-of-every-sentence/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP / MySQL &#8211; Strip Content And Only Display Images From A MySQL Table</title>
		<link>http://www.brightcherry.co.uk/scribbles/2010/06/20/php-mysql-strip-content-and-only-display-images-from-a-mysql-table/</link>
		<comments>http://www.brightcherry.co.uk/scribbles/2010/06/20/php-mysql-strip-content-and-only-display-images-from-a-mysql-table/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 20:56:10 +0000</pubDate>
		<dc:creator>Maruf</dc:creator>
				<category><![CDATA[MySQL & PHP]]></category>

		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=231</guid>
		<description><![CDATA[This is another one of those quite specific pieces of code, so I doubt many people will need it. I think the code is quite useful, so I thought i&#8217;d make a post about it. Anyways, I&#8217;m going to show you how you can pull just images out of a field in a MySQL table. [...]]]></description>
			<content:encoded><![CDATA[<p>This is another one of those quite specific pieces of code, so I doubt many people will need it. I think the code is quite useful, so I thought i&#8217;d make a post about it. Anyways, I&#8217;m going to show you how you can pull just images out of a field in a MySQL table. I used this code yesterday, to specifically pull out all images from a WordPress Blog &#8211; to look at all the images that have been posted in ALL articles.</p>
<h5>What the following PHP/MySQL code will specifcally deliver&#8230;</h5>
<ul>
<li>It will pull out ONLY images</li>
<li>If one field has multiple images, it will display ALL of them</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"><sup></sup></span><span class="left"><a rel="nofollow" href="javascript:;" onclick="javascript:showCodeTxt('p231code9'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2319"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p231code9"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//this query will only get the rows that have images in them</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span>
<span style="color: #0000ff;">&quot;SELECT [field]
FROM [table]
WHERE [field] LIKE '%&lt;img src=&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//execute the query</span>
<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;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//loop the results</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #666666; font-style: italic;">//this is the magic - preg_match matches all the images saves them into an array called images[]</span>
 <span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&lt;img[^&gt;]+&gt;/i'</span><span style="color: #339933;">,</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ENTER FIELD'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$images</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//echo out all the images</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$images</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>That&#8217;s it! The print_r will show you all the images when you load the page. The preg_match_all line can actually be used with any string to pull out image references (or whatever regulat expression you require). I&#8217;m just specifcially demonstrating how I used it with WordPress/images.</p>
<p>If you don&#8217;t want to see the images, and just want to see the actual image URL&#8217;s, you can do the following&#8230;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup></sup></span><span class="left"><a rel="nofollow" href="javascript:;" onclick="javascript:showCodeTxt('p231code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p23110"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p231code10"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//put the images[] array into a foreach loop</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$images</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">//because each entry may have multiple images, we have to loop through each row to get each image</span>
  <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$img</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//remove the &lt;img&gt; tag</span>
    <span style="color: #000088;">$img</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;img src=&quot;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$img</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//explode each image by double quotes (or single quotes depending on how you quote your images), so we know where the image URL ends!</span>
    <span style="color: #000088;">$img</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$img</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//rename the image URL to $file for ease</span>
    <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$img</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
   <span style="color: #666666; font-style: italic;">//echo out each image URL</span>
    <span style="color: #990000;">echo</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Please let mw know if anyone actually uses this code and how useful it was&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brightcherry.co.uk/scribbles/2010/06/20/php-mysql-strip-content-and-only-display-images-from-a-mysql-table/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Populate Date Dropdowns &#8211; HTML Forms</title>
		<link>http://www.brightcherry.co.uk/scribbles/2010/06/10/php-create-dynamic-date-dropdowns/</link>
		<comments>http://www.brightcherry.co.uk/scribbles/2010/06/10/php-create-dynamic-date-dropdowns/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 00:23:29 +0000</pubDate>
		<dc:creator>Maruf</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=225</guid>
		<description><![CDATA[Ok, i&#8217;m going to quickly jot down some PHP code, which dynamically populates date fields (dd/mm/yyyy) for HTML forms. I&#8217;m always using this code, but I never write it down, so i&#8217;m forever retyping it! To generate the date dropdown fields shown above, you could hardcode the values, like this&#8230;. View Code HTML1 2 3 [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, i&#8217;m going to quickly jot down some PHP code, which dynamically populates date fields (dd/mm/yyyy) for HTML forms. I&#8217;m always using this code, but I never write it down, so i&#8217;m forever retyping it!</p>
<p><img src="http://www.brightcherry.co.uk/images/blogimages/year_dropdown.jpg" title="Dynamic Date Dropdowns" alt="Dynamic Date Dropdowns" /></p>
<p>To generate the date dropdown fields shown above, you could hardcode the values, like this&#8230;.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup></sup></span><span class="left"><a rel="nofollow" href="javascript:;" onclick="javascript:showCodeTxt('p225code13'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p22513"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p225code13"><pre class="html" style="font-family:monospace;">&lt;select name=&quot;year&quot;&gt;
&lt;option value=&quot;1999&quot;&gt;1999&lt;/option&gt;
&lt;option value=&quot;2000&quot;&gt;2000&lt;/option&gt;
&lt;option value=&quot;2001&quot;&gt;2001&lt;/option&gt;
&lt;option value=&quot;2002&quot;&gt;2002&lt;/option&gt;
&lt;option value=&quot;2003&quot;&gt;2003&lt;/option&gt;
&lt;option value=&quot;2004&quot;&gt;2004&lt;/option&gt;
&lt;option value=&quot;2005&quot;&gt;2005&lt;/option&gt;
&lt;option value=&quot;2006&quot;&gt;2006&lt;/option&gt;
&lt;/select&gt;</pre></td></tr></table></div>

<p>But that&#8217;s a very tedious and long way of doing it. A better solution is to use a for loop in PHP to generate the dates. The following code i&#8217;m using automatically generates the dates with a few lines of PHP&#8230;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup></sup></span><span class="left"><a rel="nofollow" href="javascript:;" onclick="javascript:showCodeTxt('p225code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p22514"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code" id="p225code14"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>select name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;day&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?</span><span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$day</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$day</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">31</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$day</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;?</span>
                <span style="color: #666666; font-style: italic;">//this code is adding a 0 before all values less than 10</span>
                <span style="color: #666666; font-style: italic;">//you don't need this code, but I prefer to have 2 digit values</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$day</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$day</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$day</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">?&gt;</span>
		<span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?=<span style="color: #006699; font-weight: bold;">$day</span>?&gt;&quot;</span><span style="color: #339933;">&gt;&lt;</span>?<span style="color: #339933;">=</span><span style="color: #000088;">$day</span>?<span style="color: #339933;">&gt;&lt;/</span>option<span style="color: #339933;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?</span><span style="color: #b1b100;">endfor</span><span style="color: #339933;">;</span>?<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>select<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>select name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;month&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?</span><span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$month</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$month</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">12</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$month</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;?</span>
                <span style="color: #666666; font-style: italic;">//this code is adding a 0 before all values less than 10</span>
                <span style="color: #666666; font-style: italic;">//you don't need this code, but I prefer to have 2 digit values</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$month</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$month</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$month</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">?&gt;</span>
		<span style="color: #339933;">&lt;</span>option value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?=<span style="color: #006699; font-weight: bold;">$month</span>?&gt;&quot;</span><span style="color: #339933;">&gt;&lt;</span>?<span style="color: #339933;">=</span><span style="color: #000088;">$month</span>?<span style="color: #339933;">&gt;&lt;/</span>option<span style="color: #339933;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?</span><span style="color: #b1b100;">endfor</span><span style="color: #339933;">;</span>?<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>select<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>select name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;year&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?</span>
        <span style="color: #666666; font-style: italic;">//The 60 value here is the amount of years to go back</span>
	<span style="color: #000088;">$year</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//The 60 value here is the amount of years to go forward</span>
        <span style="color: #666666; font-style: italic;">//because i went back 60 years, i'm going forward 60 years so the dropdown will always have the current year, going back 60 years.</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;&lt;option&gt;<span style="color: #006699; font-weight: bold;">$year</span>&lt;/option&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$year</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;/</span>select<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>The above code will generate dropdowns for <b class="pink">day, month and year</b>! I&#8217;ve commented in areas where I felt appropriate.</p>
<p>Does anyone know a better way to do this with PHP? Would love to hear your tips&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brightcherry.co.uk/scribbles/2010/06/10/php-create-dynamic-date-dropdowns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript &#8211; How To Remove The Trailing Hash In A URL</title>
		<link>http://www.brightcherry.co.uk/scribbles/2010/04/25/javascript-how-to-remove-the-trailing-hash-in-a-url/</link>
		<comments>http://www.brightcherry.co.uk/scribbles/2010/04/25/javascript-how-to-remove-the-trailing-hash-in-a-url/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 21:48:15 +0000</pubDate>
		<dc:creator>Maruf</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.brightcherry.co.uk/scribbles/?p=222</guid>
		<description><![CDATA[Ok, this is a quick note to myself, because I always seem to forget this code, and I have no idea why, because it&#8217;s so simple. So, the scenario is that when I&#8217;m writing AJAX code, a lot of the times I use a hyperlink to trigger an action. For example, look at the following [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, this is a quick note to myself, because I always seem to forget this code, and I have no idea why, because it&#8217;s so simple.</p>
<p>So, the scenario is that when I&#8217;m writing AJAX code, a lot of the times I use a hyperlink to trigger an action. For example, look at the following code&#8230;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup></sup></span><span class="left"><a rel="nofollow" href="javascript:;" onclick="javascript:showCodeTxt('p222code17'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p22217"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p222code17"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;#&quot;</span> <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;open_div&quot;</span><span style="color: #339933;">&gt;</span>Open Div<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;show_content&quot;</span> style<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;display:none&quot;</span><span style="color: #339933;">&gt;</span>Show stuff here....<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.open_div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#show_content'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Ok, so what that code is basically doing is displaying a link, with the anchor text, <b class="pink">Open Div</b>. When the link is clicked, the <b class="pink">show_content</b> div will appear, with the containing content.</p>
<p>But the problem is, if I clicked that link on the Bright<b class="pink">Cherry</b> homepage (assuming the code was there), the URL would change to this&#8230;</p>
<p><img src="http://www.brightcherry.co.uk/images/blogimages/brightcherry_hash.jpg" title="Trailing Hash" alt="Trailing Hash" /></p>
<p>Anyone else experience this? It&#8217;s not actually a problem, but it irritates me because I find it ugly and weird (probably because I&#8217;m very particular).</p>
<h4>The Solution</h4>
<p>The fix ISN&#8217;T to simply remove the hash (#) from the A TAG, because then the code won&#8217;t work.</p>
<p>To stop the trailing hash from the URL, you just need to do the following&#8230;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup></sup></span><span class="left"><a rel="nofollow" href="javascript:;" onclick="javascript:showCodeTxt('p222code18'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p22218"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p222code18"><pre class="html" style="font-family:monospace;">// replace the hash with the following
&lt;a href=&quot;javascript:void(0);&quot; class=&quot;open_div&quot;&gt;Open Div&lt;/a&gt;</pre></td></tr></table></div>

<p>Ahhh, that&#8217;s better.</p>
<p>Out of curiosity, has this problem actually bothered anyone else?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brightcherry.co.uk/scribbles/2010/04/25/javascript-how-to-remove-the-trailing-hash-in-a-url/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
