News & Blog

phpMyAdmin

Perform Search For String Across Entire Database in phpMyAdmin

June 16th, 2014 - Posted by Steve Marks to MySQL, Web Development.
Searching for a word or phrase within one MySQL table can be easily achieved with an SQL query. Doing a search across a whole database becomes a little bit more complex should you wish to do this with a query. Thankfully, if you use phpMyAdmin there is a built-in feature that enables you d...

Format a Number Within a String Using PHP preg_replace() Function

September 14th, 2012 - Posted by Steve Marks to PHP, Web Development.
Let’s imagine we have the following string: I owe 1000000 GBP to the bank. I shall pay 2500 GBP each month for the following 1000 years. The above statement is luckily not true, however it is a good representation of a scenario where we have numbers contained within a string that we ...

Getting the First Word of a String with MySQL

November 10th, 2010 - Posted by Steve Marks to MySQL, Web Development.
I was recently assigned the task of getting the first word from a field in a MySQL table. In my case it was getting the first part of a customers postcode. Following a quick look through the MySQL reference manual I was guided towards the SUBSTRING_INDEX() function. By using this function ...

How to Get the Last Character in a String with PHP

November 7th, 2010 - Posted by Steve Marks to Web Development.
There a number of ways to get the last character in a string by using PHP. The simplest way I find however is to use the substr() function like so: $str = "This is a string"; echo substr($str, -1); The above example would return ‘g’. By passing a negative value as the second pa...

Removing All Spaces From a String Using Javascript

October 20th, 2010 - Posted by Steve Marks to Javascript / jQuery, Web Development.
I recently wrote about how to remove all occurences of a character from a string using JavaScript by combining the replace() function and a regular expression. This works great but a problem arises when we use this method to try and replace all occurrences of a space. Using the previously ...

JavaScripts replace() Function Only Replacing First Occurrence

October 3rd, 2010 - Posted by Steve Marks to Web Development.
The replace() function in JavaScript is useful for finding a substring within a string and replacing it with a new substring. What the official JavaScript documentation doesn’t state very clearly however is that the function will only replace the first occurrence. But what if we need...