On a project I was working on recently, I was pulling in some css for iPhone users using PHP with the following code: <php if (strpos($_SERVER['HTTP_USER_AGENT'],"iPhone")) { ?> … CUSTOM CSS FOR IPHONE… <php } ?> This will also work for iPhones and iPod Touch: <php if (strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod')) { ?> … CUSTOM CSS… […]
Comments Off on CSS for iPhone's eyes only (watch out for the cache)
Showing random quotes isn'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't want to show the same quote twice. That […]
13 Jan, 2010
Posted by: Jennifer In: PHP
This is a really silly little trick – but if you have a PHP page that has a © copyright year at the bottom – there is no reason you should be updating that every year (unless it's just something you overlooked initially) As you get requests from clients now that we're in a new […]
23 Feb, 2008
Posted by: Jennifer In: PHP
On one of my projects recently, they needed a dynamic bar graph that would show the progress towards a goal of donations. I've never done something like that before, and it turns out it's actually pretty simple to do. I'll explain how the code works and then include everything at the end.
13 Jul, 2007
Posted by: Jennifer In: PHP
I probably already have this posted somewhere, I know I use it a ton but always have to look it up for the exact syntax. Here's how you can get the name of the current file (ie. if your file is "aboutus.php" this will echo "aboutus.php") <?php $currentFile = $_SERVER["PHP_SELF"]; $parts = Explode('/', $currentFile); echo […]
28 May, 2007
Posted by: Jennifer In: PHP
I had written this tutorial sometime ago with the intention of cleaning it up and posting it here. Finally getting around to this. The original purpose of the tutorial was to explain how to use session cookies to a friend of mine who was working on a form that was a number of pages long. […]
For a long time I resisted the urge to put ads on the site. I'm sure you've noticed I finally caved in this past year. I've tried to keep it relatively unobtrusive. In one case I was contacted directly to put an ad up on one of my category pages in the content area. I […]
24 Mar, 2007
Posted by: Jennifer In: mySQL|PHP
Another mini-cheatsheet… I know this stuff, but I'm always looking it up for the exact syntax. Connect to MySQL and to the database – mysql_connect $connect = mysql_connect("localhost", "mysqluser", "userpassword") or die(mysql_error()); Select the database – mysql_select_db mysql_select_db("databasename", $connect) or die(mysql_error()); Close connection – mysql_close mysql_close($connect) or die(mysql_error()); Select data from the database – mysql_query […]
Well, this was fun! I just made a store locator for a client using PHP and AJAX! 😀 I was basically following the instructions from this page: SomeCoders.com (Retrieving database information with AJAX, PHP and MySQL) Take a look…