Category Archives: PHP

Keeping Your Website’s Copyright Date Current with PHP

Never have an outdated copyright date (displaying © 2007 in 2010) again. It’s super easy, and is only one line of code.
&copy; <?php echo date(‘Y’); ?>
It seems it’s more prevalent around the turn of the calendar year, but why not cross it off your yearly list without even doing anything?

Convert an ALL CAPS string to first character capitalized only in PHP

Nothing new to you php gurus, but hope this can help somebody looking for a quick fix – great to filter user inputs in things like addresses, company names, and yes regular ole names. It utilizes PHP’s ucwords() and strtolower():

<?
$userInput1 = “MR. CAPITAL LETTERS”;
$userInput2 = “mrs. lowercase letters”;
ucwords(strtolower($userInput1)); //outputs “Mr. Capital Letters”
ucwords(strtolower($userInput2)); [...]

States HTML Select List w/ PHP Selected Value

I always have trouble finding this, so here it is.  The if statement in the checkState() function can be replaced with anything you like to select the option by default…
<?
function checkState($state) {
if ($row['state'] == $state) {
echo ‘ selected=”selected”‘;
}
}
?>
<select name=”state” id=”state”>
<option value=”–”<? checkState(”) ?>>Select…</option>
<option value=”AL”<? checkState(‘AL’); [...]

<From the blog>

© 2010 Rainmaker Web Design | 244 Bloomfield Street | Athens, GA 30605 | V: (770) 377-6345 | F: (770) 640-1599