The weblog survey
So, I took the weblog survey, since I’ve been seeing those buttons all over the place.
On at least one site, I reloaded the page once or twice to see if the button changed. Nope. Then when I finished the survey, I discovered that you choose from one of five buttons. Now, that could be boring. This should be randomized.
First, if you can embed a PHP block (say, if it’s going in a sidebar) you could just put in this code to select one of the buttons at random:
<?php
$options = array("statistic", "bell", "science", "cameron", "powerlaw");
echo '<a href="http://blogsurvey.media.mit.edu/request"><img src="http://blogsurvey.media.mit.edu/images/survey-', $options[rand(0,4)], '.gif" alt="Take the MIT Weblog Survey" style="border:none" /></a>';
?>
(If your web host is using a version of PHP newer than 4.2, and they should be, you don’t need to seed the rand() function.)
But that doesn’t work well within a blog entry, so let’s try another route. You could create a file, like survey.php, and put this code in it:
<?php
$options = array("statistic", "bell", "science", "cameron", "powerlaw");
$image_url = "http://blogsurvey.media.mit.edu/images/survey-" . $options[rand(0,4)] . ".gif";
header("Location: $image_url");
exit;
?>
…then, with that script on your site, call it from the src value of the img tag. Or, you could just take my word for it that it works, and use mine, by using this HTML:
<a href="http://blogsurvey.media.mit.edu/request">
<img src="http://www.flashesofpanic.com/survey.php" alt="Take the MIT Weblog Survey" style="border:none" />
</a>
…and it will look like this:
Now Playing: Alameda from Either/Or by Elliott Smith