<?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>scriptygoddess &#187; Script snippet</title>
	<atom:link href="http://www.scriptygoddess.com/archives/category/scripts/script-snippet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scriptygoddess.com</link>
	<description></description>
	<lastBuildDate>Thu, 08 Dec 2011 18:23:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Showing multiple random quotes</title>
		<link>http://www.scriptygoddess.com/archives/2010/04/01/showing-multiple-random-quotes/</link>
		<comments>http://www.scriptygoddess.com/archives/2010/04/01/showing-multiple-random-quotes/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 05:03:39 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Script snippet]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/?p=1629</guid>
		<description><![CDATA[Showing random quotes isn&#039;t anything new. When I needed to do something similar on a site recently, there were plenty of pre-written scripts to choose from. The trick however, was that I wanted to show more than one quote at a time (and of course I didn&#039;t want to show the same quote twice. That [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Showing random quotes isn&#039;t anything new. When I needed to do something similar on a site recently, there were plenty of pre-written scripts to choose from. The trick however, was that I wanted to show more than one quote at a time (and of course I didn&#039;t want to show the same quote twice. That wasn&#039;t as easy to find.  (I&#039;m sure there&#039;s variations out there, but now I&#039;ll always have a place to find mine) <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>First step is to load all the quotes you want into an array:</p>
<p><code>$quotes[] = "This is line 1";<br />
$quotes[] = "This is line 2";<br />
$quotes[] = "this is line 3";<br />
$quotes[] = "This is another line";<br />
$quotes[] = "This is yet another line";<br />
$quotes[] = "Line 6";</code></p>
<p>Now get a handful of keys using <a href="http://php.net/manual/en/function.array-rand.php">array_rand</a>:</p>
<p><code>$rand_keys = array_rand($quotes, 2);</code></p>
<p>We specified to get two random keys from the $quotes array &#8211; (You can grab more if you want, just change the &#034;2&#034;)</p>
<p>Now that we have our random keys &#8211; you can either list them out one by one like this:</p>
<p><code>//show the first quote...<br />
echo $quotes[$rand_keys[0]];<br />
//show the second quote<br />
echo $quotes[$rand_keys[1]];</code></p>
<p>Or you can loop through the keys like this:</p>
<p><code>foreach ($rand_keys as $value) {<br />
	echo $quotes[$value]."&lt;br /&gt;";<br />
}</code></p>
<p>That&#039;s all there is to it.</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2010/04/01/showing-multiple-random-quotes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Force File Download</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/09/force-file-download/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/02/09/force-file-download/#comments</comments>
		<pubDate>Fri, 09 Feb 2007 22:33:52 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Bookmarks]]></category>
		<category><![CDATA[PHP Related]]></category>
		<category><![CDATA[Script snippet]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/09/force-file-download/</guid>
		<description><![CDATA[How to force a file to download (without having to zip it up). $filename = "secure/writeToFile.doc"; header("Content-Length: " . filesize($filename)); header('Content-Type: application/msword'); header('Content-Disposition: attachment; filename=writeToFile.doc'); readfile($filename); a few other content types &#8211; lots more at the above link&#8230; "pdf": "application/pdf" "zip": "application/zip" "xls": "application/vnd.ms-excel" "ppt": "application/vnd.ms-powerpoint" "gif": "image/gif" "png": "image/png" "jpg": "image/jpg" "mp3": "audio/mpeg" "mp3": [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><a href="http://actionscript.org/forums/showthread.php3?t=89784">How to force a file to download (without having to zip it up).</a></p>
<p><code>$filename = "secure/writeToFile.doc";</code></p>
<p><code>header("Content-Length: " . filesize($filename));<br />
header('Content-Type: application/msword');<br />
header('Content-Disposition: attachment; filename=writeToFile.doc');</code></p>
<p><code>readfile($filename);</code></p>
<p>a few other content types &#8211; lots more at the above link&#8230;</p>
<p><code>"pdf": "application/pdf"<br />
"zip": "application/zip"<br />
"xls": "application/vnd.ms-excel"<br />
"ppt": "application/vnd.ms-powerpoint"<br />
"gif": "image/gif"<br />
"png": "image/png"<br />
"jpg": "image/jpg"<br />
"mp3": "audio/mpeg"<br />
"mp3": "audio/mp3"<br />
"wav": "audio/x-wav"<br />
"mpe": "video/mpeg"<br />
"mov": "video/quicktime"<br />
"avi": "video/x-msvideo"</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2007/02/09/force-file-download/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Store all post variables/values in a session</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/07/store-all-post-variablesvalues-in-a-session/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/02/07/store-all-post-variablesvalues-in-a-session/#comments</comments>
		<pubDate>Thu, 08 Feb 2007 03:02:03 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Script snippet]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/07/store-all-post-variablesvalues-in-a-session/</guid>
		<description><![CDATA[This is one of those things I use all the time but because I can&#039;t remember things like this, I always have to look for the exact code to do it&#8230; This will take all the values submitted in a form and store them in a session: foreach($_POST as $k=&#62;$v) { $_SESSION[$k]=$v; } And when [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This is one of those things I use all the time but because I can&#039;t remember things like this, I always have to look for the exact code to do it&#8230;</p>
<p>This will take all the values submitted in a form and store them in a session:</p>
<p><code>foreach($_POST as $k=&gt;$v) {<br />
$_SESSION[$k]=$v;<br />
}</code></p>
<p>And when you&#039;re ready to dump the session values&#8230;</p>
<p><code>session_unset();// reset session array<br />
session_destroy();   // destroy session.</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2007/02/07/store-all-post-variablesvalues-in-a-session/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Javascript set selection in select element</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comments</comments>
		<pubDate>Tue, 06 Feb 2007 21:29:30 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Script snippet]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/</guid>
		<description><![CDATA[I needed to set the selection of a drop down menu. As far as I can tell, if you don&#039;t know the &#034;index&#034; value, then you just have to loop through to set the item as selected. If there&#039;s an easier way to do this, please speak up in the comments. I spent WAY too [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I needed to set the selection of a drop down menu. As far as I can tell, if you don&#039;t know the &#034;index&#034; value, then you just have to loop through to set the item as selected. If there&#039;s an easier way to do this, please speak up in the comments. I spent WAY too long hunting for a better solution, but this was the only thing that worked:</p>
<p><code>for (var i=0; i &lt; document.formname.dropdownboxname.length; i++) {<br />
if (document.formname.dropdownboxname[i].value == <em>"value"</em>) {<br />
document.formname.dropdownboxname[i].selected = true;<br />
}<br />
}</code></p>
<p><strong>Update</strong> Posting my comment in the main post &#8211; because this is the way to do it right: Use jQuery because it rules.</p>
<p>Use this plugin:<br />
<a href="http://www.texotela.co.uk/code/jquery/select/">http://www.texotela.co.uk/code/jquery/select/</a></p>
<p>And this code:<br />
<code>$(document).ready(function() {<br />
$(”#selectboxname”).selectOptions(”The Select Value”, true);<br />
});</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Get current URL with PHP</title>
		<link>http://www.scriptygoddess.com/archives/2007/01/29/get-current-url-with-php/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/01/29/get-current-url-with-php/#comments</comments>
		<pubDate>Mon, 29 Jan 2007 23:02:38 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Script snippet]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/01/29/get-current-url-with-php/</guid>
		<description><![CDATA[Because I was having a &#034;duh&#034; moment. $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] No related posts. Related posts brought to you by Yet Another Related Posts Plugin.
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Because I was having a &#034;duh&#034; moment. <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><code>$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2007/01/29/get-current-url-with-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>gifs that execute a php script</title>
		<link>http://www.scriptygoddess.com/archives/2004/10/19/gifs-that-execute-a-php-script/</link>
		<comments>http://www.scriptygoddess.com/archives/2004/10/19/gifs-that-execute-a-php-script/#comments</comments>
		<pubDate>Tue, 19 Oct 2004 16:37:59 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Lessons learned]]></category>
		<category><![CDATA[Script snippet]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/10/19/gifs-that-execute-a-php-script/</guid>
		<description><![CDATA[Problem: (somewhat in line with my last post) I needed to run a script in the &#034;background&#034;, but I only had the ability to present the script as a .gif. Solution: actually, I came up with two ways of doing this and both use .htaccess to pull it off. 1) I&#039;m a gif but really [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Problem: (somewhat in line with my last post) I needed to run a script in the &#034;background&#034;, but I only had the ability to present the script as a .gif.</p>
<p>Solution: actually, I came up with two ways of doing this and both use .htaccess to pull it off.</p>
<p><strong>1) I&#039;m a gif but really I&#039;m a php script</strong><br />
This one is fairly straightfoward. I put my script in a seperate directory, (that doesn&#039;t actually include any images!) and renamed it from filename<strong>.php</strong> to filename<strong>.gif</strong> (or filename<strong>.jpg</strong>) (Yes, I know it&#039;s not really an image file. Hang in there)</p>
<p>Then, in the htaccess file for JUST THAT FOLDER! (similar to <a href="http://www.scriptygoddess.com/archives/2003/04/02/running-php-on-a-html-or-htm-page/">this trick</a>) I added this:<br />
<code>AddType application/x-httpd-php .php .jpg .gif</code></p>
<p>FYI &#8211; in your php file (that now looks like a .gif or .jpg) make sure you don&#039;t have any headers/text echoed, and at the end of the file add this to your php code:<br />
<code>header('Content-Type: image/gif');<br />
@readfile( '/SERVERPATH/TO/A/REAL/IMAGE/spacer.gif' );</code></p>
<p>You can then include the &#034;script&#034; as if it were an image file, it will run the script, but only display a gif to the user.</p>
<p>You can even pass it variables like filename.gif?somevariable=somevalue&#038;anotervariable=anothervalue, but there&#039;s another way to do that too without the ugly URL.</p>
<p><strong>2) I&#039;m a gif that&#039;s actually a php script super-powered with rewrite</strong><br />
Ok, starting from the beginning. You have your script (filename.php) in a folder, add the following to the .htaccess file in that folder:<br />
<code>RewriteEngine On<br />
RewriteBase /<br />
RewriteRule ^(.*)/(.*)/spacer.gif /YOURFOLDER/FILENAME.php?somevar=$1&#038;anothervar=$2 [QSA]</code></p>
<p>Before we continue, I must tell you that I dont&#039; completely understand rewrite rules. There&#039;s a LOT of holes in my knowledge. So if you have a better way, PLEASE post it in the comments. I would LOVE to be able to understand what the hell I&#039;m doing. LOL.</p>
<p>OK, moving along. Now you can call your script by actually calling that &#034;phantom&#034; spacer.gif, with the variables in the URL as if they&#039;re directories like this:</p>
<p><code>http://www.yourdomain.com/YOURFOLDER/somevalue/anothervalue/spacer.gif</code></p>
<p>Again, make sure you have this at the end of you php code in your filename.php:<br />
<code>header('Content-Type: image/gif');<br />
@readfile( '/SERVERPATH/TO/A/REAL/IMAGE/spacer.gif' );</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2004/10/19/gifs-that-execute-a-php-script/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Copy values from one field to another with javascript</title>
		<link>http://www.scriptygoddess.com/archives/2004/10/08/copy-values-from-one-field-to-another-with-javascript/</link>
		<comments>http://www.scriptygoddess.com/archives/2004/10/08/copy-values-from-one-field-to-another-with-javascript/#comments</comments>
		<pubDate>Fri, 08 Oct 2004 11:47:30 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Bookmarks]]></category>
		<category><![CDATA[Script snippet]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/10/08/copy-values-from-one-field-to-another-with-javascript/</guid>
		<description><![CDATA[Needed to write a javascript that would take the values of one select box &#8211; and copy it to all the other select boxes on the same page. I found this script which will take all the values from one set of fields &#8211; and copy it to another set of fields (kind of like [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Needed to write a javascript that would take the values of one select box &#8211; and copy it to all the other select boxes on the same page. I found <a href="http://javascript.internet.com/forms/copy-fields.html">this script which will take all the values from one set of fields &#8211; and copy it to another set of fields</a> (kind of like those billing / shipping forms, where if your billing and shipping address is the same, you just check a box &#8211; and it prefills the other set of fields for you with the same info from above). And while it &#034;inspired me&#034; &#8211; it wasn&#039;t exactly what I was looking for. In my case &#8211; I didn&#039;t know the exact names of all the other fields, and I didn&#039;t even know how many of them there would be &#8211; they are generated dynamically. It&#039;s a pretty simple script, but here it is anyway:<br />
<h3>&lt;script type=&#034;text/javascript&#034;&gt;<br />
function applyToAll()<br />
{<br />
for (var i=0; i&lt; document.YOURFORMNAME.length; i++) {<br />
document.YOURFORMNAME[i].selectedIndex = document.YOURFORMNAME.NAMEOFMAINSELECT.selectedIndex;<br />
}<br />
}<br />
&lt;/script&gt;</h3>
<p>So your select box probably looks like this:</p>
<h3>&lt;select name=&#034;NAMEOFMAINSELECT&#034;&gt;<br />
&lt;option value=&#034;1&#034;&gt;1&lt;/option&gt;<br />
&lt;option value=&#034;2&#034;&gt;2&lt;/option&gt;<br />
&#8230; etc. &#8230;<br />
&lt;/select&gt;</h3>
<p>and then, next to the select box (which will be the one all the others are based on) put a link like this:</p>
<h3>&lt;a href=&#034;javascript:applyToAll()&#034;&gt;Apply To All&lt;/a&gt;</h3>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2004/10/08/copy-values-from-one-field-to-another-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: working with multiple databases</title>
		<link>http://www.scriptygoddess.com/archives/2004/06/15/php-working-with-multiple-databases/</link>
		<comments>http://www.scriptygoddess.com/archives/2004/06/15/php-working-with-multiple-databases/#comments</comments>
		<pubDate>Wed, 16 Jun 2004 03:32:24 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Lessons learned]]></category>
		<category><![CDATA[Script snippet]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/06/15/php-working-with-multiple-databases/</guid>
		<description><![CDATA[I&#039;m in the process of moving a few other blogs over to use WP &#8211; one of which makes calls to a seperate database unrelated to WP. This proved to cause a conflict. After many hours of trying to figure out where the specific conflict was &#8211; I narrowed it down to my mysql_select_db line. [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I&#039;m in the process of moving a few other blogs over to use WP &#8211; one of which makes calls to a seperate database unrelated to WP. This proved to cause a conflict. After many hours of trying to figure out where the specific conflict was &#8211; I narrowed it down to my <em><a href="http://us2.php.net/manual/en/function.mysql-select-db.php">mysql_select_db</a></em> line. Apparently selecting your database this way &#8211; even if you close your mysql connection &#8211; and then select a different database later on &#8211; it can cause you headaches (and make you stay up later than you had intended to) LOL! =Yawn=</p>
<p>The remedy was specifying the databasename when referencing the table and avoiding using the <em>mysql_select_db</em> line altogether.</p>
<p>So instead of code that looked like this:<br />
<code>$databaseConnection = mysql_connect($databaseServer, $databseUsername, $databasePassword) or<br />
die ('I can't connect to the database.');<br />
mysql_select_db($databaseName,$databaseConnection);<br />
$query = "SELECT * from tablename;";<br />
$result = mysql_query($query);</code></p>
<p>I changed it to this and it seemed to work:<br />
<code>$databaseConnection = mysql_connect($databaseServer, $databseUsername, $databasePassword) or<br />
die ('I can't connect to the database.');<br />
$query = "SELECT * from " . $databaseName . ".tablename;";<br />
$result = mysql_query($query,$databaseConnection);</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2004/06/15/php-working-with-multiple-databases/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Quick Tags for comments</title>
		<link>http://www.scriptygoddess.com/archives/2004/06/10/quick-tags-for-comments/</link>
		<comments>http://www.scriptygoddess.com/archives/2004/06/10/quick-tags-for-comments/#comments</comments>
		<pubDate>Fri, 11 Jun 2004 00:56:55 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Script snippet]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/06/10/quick-tags-for-comments/</guid>
		<description><![CDATA[Since Alex released his js quick tags &#8211; it seemed like the perfect thing to add to the comments form so that people could put in the html tags more easily. However, while his script is really powerful &#8211; just for the comments form, it&#039;s more than what&#039;s needed. So I stripped it down to [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Since <a href="http://www.alexking.org/blog/2004/06/03/js-quicktags-under-lgpl/">Alex released his js quick tags</a> &#8211; it seemed like the perfect thing to add to the comments form so that people could put in the html tags more easily. However, while his script is really powerful &#8211; just for the comments form, it&#039;s more than what&#039;s needed. So I stripped it down to the most basic version &#8211; using only the most common HTML tags used in comments &#8211; italic, bold, and links.</p>
<p>Here are the instructions on how to integrate it into your (wordpress) comments:<br />
<span id="more-652"></span><br />
First and foremost &#8211; if you want to add code, or use the full version &#8211; you can download that from Alex&#039;s site.</p>
<p>To use the &#034;mini&#034; version I made:</p>
<p>1) <a href="http://www.scriptygoddess.com/downloads/js_quicktags-mini.zip">Download the js file</a> and upload it to the root of your domain.</p>
<p>2) Open up your wp-comments.php page&#8230; Look for the beginning of the comments form &#8211; (search for <i>&lt;form</i> in the file) and put this just above it:<br />
<h3>&lt;script src=&#034;/js_quicktags-mini.js&#034; type=&#034;text/javascript&#034;&gt;&lt;/script&gt;</h3>
<p>Look for the text area field for comments which looks like this <i>&lt;textarea name=&#034;comment&#034; id=&#034;comment&#034; cols=&#034;40&#034; rows=&#034;6&#034; tabindex=&#034;4&#034;&gt;&lt;/textarea&gt;</i> and add this directly above it:</p>
<h3>&lt;script type=&#034;text/javascript&#034;&gt;edToolbar();&lt;/script&gt;</h3>
<p>And add this BELOW the textarea field:</p>
<h3>&lt;script type=&#034;text/javascript&#034;&gt;var edCanvas = document.getElementById(&#039;comment&#039;);&lt;/script&gt;</h3>
<p>This is the method I&#039;m using on this site &#8211; although I added the &#034;h3&#034; tag just for the one I use, since that&#039;s what I use to stylize code on this site. You can easily add more&#8230; or start from scratch using Alex&#039;s.</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2004/06/10/quick-tags-for-comments/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Random with MySQL</title>
		<link>http://www.scriptygoddess.com/archives/2004/06/02/random-with-mysql/</link>
		<comments>http://www.scriptygoddess.com/archives/2004/06/02/random-with-mysql/#comments</comments>
		<pubDate>Thu, 03 Jun 2004 02:14:15 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Script snippet]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2004/06/02/random-with-mysql/</guid>
		<description><![CDATA[Guest Authored by<br />
Michelle - <a href="http://usr-bin-mom.com/">usr-bin-mom.com/</a>
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I have a random quote and also a random link on my sidebar.  Since I have 99 links and 190+ quotes, it was easiest to use a MySQL db to manage it.  This is the query I was using:</p>
<h3>$sql = &#034;SELECT * FROM blogroll ORDER BY rand() LIMIT 1&#034;;</h3>
<p>The problem I had was that it wasn&#039;t really random.  When I had about 10 links in my blogroll, I hit refresh 80 times and got the first entry EVERY TIME.  It worked better when I had more entries, but I still got that first one way too often.  I tried to use the mt_rand() function, but it wouldn&#039;t work in the query.  I had create a variable that used mt_rand() to pick a number within my range and then call that id in the query.  So when I deleted a link or added a new one, it broke.</p>
<p>Then I found the following on <a href="http://php.net"; target="_blank">php.net</a>:</p>
<h3>$sql = &#034;SELECT * FROM blogroll ORDER BY rand(&#034; . time() . &#034; * &#034; . time() . &#034;) LIMIT 1&#034;;</h3>
<p>This works MUCH better, and it&#039;s showing a lot of links and quotes that almost never showed up before.  Hope that helps someone!</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2004/06/02/random-with-mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

