Here's a handy little PHP function I threw together to retrieve valid entries for a MySQL ENUM/SET column, handy for generating dynamic radio group/checkbox/multiple select HTML elements:
PHP:
-
// grab possible SET/ENUM values and return an array
-
function getPossibleValues($table,$field){
-
-
$query = "SHOW COLUMNS FROM `$table` LIKE '$field'";
-
-
-
-
-
-
return $options;
-
} else {
-
-
return false;
-
}
-
-
}
November 23rd, 2005
The ubiquitous bloke in the pub is the bloke who can get you anything. He's also a web designer. Or he knows a web designer. Rather, he knows someone whose brother is a web designer and can 'knock you up a website, no problems'.
Its always amazed me that no one would trust someone to 'knock you up a car' or 'get you a cracking deal on a new tv'. No, you'd tend to go to the experts to get a car or a new tv - especially as they know what they are talking about.
November 21st, 2005
Every site on the interweb needs a domain name to be functional. The question is, what constitutes a good domain name? Anyone looking to register a new domain name these days will be hard pressed to find one that satisfies the following:
- Available for registration
- Actually relates to the site content
- Has a decent domain extension
- Optional: contains company name
We've all tried to register a domain to be told its not free. Maybe my word power is low, but I can never locate the *perfect* domain name - of course, JellyandCustard.com is that exception to the rule!
Continue Reading November 18th, 2005
There's been quite an increase recently in online income stream sites. These are basically sites that are tailored to a certain subject, and alongside the content, a few targetted adverts are placed in the hope that you, the visitor, will click on them. A good site will get a good google ranking, and a fairly decent stream of visitors. Some of these visitors will inevitable click on your adverts, and you make the money for the clickthrough. That's money that you make for doing nothing apart from setup a site, and then some search engine optimisation/listings.
November 16th, 2005
Not everyone is aware of this fact, so I thought I'd share it. You can have a single form, with multiple submit buttons, and then determine which button was clicked as to what action to take. Take the following code:
If your user clicks on the "edit" button, then $_POST["edit"] will be available, and the same if they click on the "delete" button. You can test for these buttons within your PHP code, and then perform the related actions:
PHP:
-
if(isset($_POST["edit"]) &&
trim($_POST["edit"])!==
'') {
-
//they clicked edit
-
//perform INSERT SQL Query
-
} elseif(isset($_POST["delete"]) &&
trim($_POST["delete"])!==
'') {
-
//they clicked delete
-
//perform DELETE SQL Query
-
} else {
-
//nothing has been clicked
-
//load initial form
-
}
November 16th, 2005
As an avid Apple user, I'm always on the lookout for interesting and useful apps.
I stumbled across Shiira the other day and was pleasantly suprised. Yes, it is *another* browser, but its exceptionally fast. Its based upon Web-Kit (the same foundations as Safari) and so has great compatibility, yet it appears to render pages a lot faster than Safari does...
Give it a shot.
November 15th, 2005
When I reformatted my server and put Fedora Core 4 on, I had a marked decrease in transfer speeds. Before the format, i was getting about 3mb/sec, which although is slow over a 100mbit network, it was bearable. However, after the format, I had speeds on scp throttling at about 60Kb/sec!
The confusing thing was that transfers over http and ftp were going at about 9mb/sec, ruling out any hardware problems. After quite a bit of hunting around the internet, I stumbled upon an article that I've now misplaced the link for :(.
Anyhow, the fix is below.
November 15th, 2005
I decided to reformat my local webserver the other day. This server generally runs all my code on it before its published onto the web. I was using Fedora Core 4 Test 3, but decided to lose some stuff I've installed on there, and put a full release of FC4 on.
I settled on the following LAMP options:
I decided that I'd stick Oracle XE on as well, and have a play with that. Surely if MySQL is that simple to install then Oracle can't be that much harder! Or so I thought...
Read the full article (671 words & 1 image)
Continue Reading November 15th, 2005
Unfortunately, there is no inbuilt MySQL function to count the occurance of a character in string. By counting the number of characters in the original string, then temporarily 'deleting' the character you want to count and counting the string again, subtracting the first count from the second, you get the number of occurances:
SELECT LENGTH('foobarfoobarfoobar') - LENGTH(REPLACE('foobarfoobarfoobar', 'b', '')) AS `occurances`
--> 3
Obviously, in this example 'b' is the string you want to count the number of occurances of.
You can use the same principle to count the number of lines in a field, by adding one to the difference:
November 8th, 2005
Next Posts