Almost a year ago I wrote a quick article on how you can strip off characters using PHP’s built in function substr. But after reading it again, even I was not clear how it worked so how would it ever help anyone. First, if you only want to pull on character from a string, it’s [...]
You now can look in almost any website or web application where the background colors are alternating. This is a great (and easy) way to improve the user interface for the end users. Here’s a quick explanation of what’s going on in the demo file below: First we set the alternating backgrounds we want to [...]
I was going to be a good Bellsouth customer and try out their new “free” personality test when I get this SQL error. This can mean a whole heap of personal issues I’m going to have to deal with: I really do have a twin brother! I’m so common I get a SQL duplcate enty [...]
Here’s a quick snip of code to help you easily manage your files by finding out the time the file was created or modified and also the time of the file. $file = ‘image.jpg’; // FILE TIME $filetime = filemtime($file); // displays in Seconds since the Unix Epoch echo date(“M j, Y”, $filetime); // would [...]
Here’s a quick way to strip off characters from a string using PHP’s function substr. <? $var = ’05 Delete’; $var = substr($var,0,2); echo($var); // returns “05″ ?> If you wanted to strip off the characters from the end of a string, just change the “2″ to “-2″ and it will strip off the last [...]
Just another quick way to automate the simple process of creating HTML selects with a function. This small function with also remember which value was selected by checking it against the $_POST value and adding a selected=”SELECTED” to that option. 2 dimentional array: $people_array = array( ’1′ => ‘Bob’, ’2′ => ‘James’, ’3′ => ‘Jessi’, [...]
Being a very big music buff, I love being able to see what my music habits are. I’m currently using the most up-to-date version of Winamp, which does a good job of keep a history of what I listen to, but I wanted this info on the web for the world to see. Fortunatly, Last.fm [...]
Quite a few times during projects I only want to find a single value from the database. But rather than setting up WHILE loop, I’ve been using a quick function that does two things perfectly. Here’s the function: // returns single result function mysql_one_data($query) { $one=mysql_query($query); $r=mysql_fetch_row($one); return($r[0]); } // returns single array function mysql_one_array($query) [...]
After coding for a while things no longer become “fun” to do over and over. One of those things for me is forms and particularly for this article a state drop down. Below is an array of all the current states along with a quick example of how to use it.
One of the sites that I’ve been working on recently for some odd reason would not log users in (or at least not constantly). After looking into it further, I realized it had to do with the PHP function “header” redirecting the user if the login query was successfully. The problem came when a user [...]