Archive for August, 2008
Calculating value from percent
This short tutorial is aimed to help you how to calculate the percent value from a total.
Read moreGet maximum ID from a table
To get the maximum id from a table you can use the MAX() function.
Here’s an example:
SELECT MAX(id_field_here) as max_id FROM `table`;
How to hide notice errors
Hi,
The PHP notice errors are sometimes frustrating and you are tired of seeing them when you are working on your scripts. They are showed at the beggining of your pages and may reveal confidential information to the visitor like the path to the file or the php file name (in case you are using friendly [...]
How to make a selection based on the beginning value
An SQL command that selects the field
Read moreHow to make an alphabetical search
Hello,
This tutorial is aimed to help you how to make an alphabetical search using MySQL. Many sites use it these day and we will show you how do they do it.
Let’s suppose you have a business directory and you want to display the listings that are starting with a specific letter or a non-letter character [...]
How to add a prefix to a field’s value
Greetings,
Ever wanted to add a preffix to a mysql field’s value? The CONCAT string function can help you. Here’s how you can do it:
UPDATE `your_table` SET field_name = CONCAT(’my prefix here ‘, field_name)
where field_name=’the field value here’; #optional condition
Example: You can use this command to add a prefix for a telephone number.
Good luck!
How to add a suffix to a field’s value
Greetings,
Ever wanted to add a suffix to a mysql field’s value? The CONCAT string function can help you. Here’s how you can do it:
UPDATE `your_table` SET field_name = CONCAT(field_name, ‘ my suffix here’)
where field_name=’the field value here’; #optional condition
So if the field’s value if “New York” and you add the suffix ” City” then our [...]
Read moreHighlight (Search) Key Words in a Text
This function is useful to highlight words from a text. For instance, the search results from your site can be highlighted.
Read moreChecking the beginning of a string (prefix)
Greetings,
This is a function which will help you to determine if a text starts which a specific string. It’s useful when you’re working with dynamic variables and you need to check if the text matches some patterns like its beginning. For instance you have an array and you want to output only files that have [...]
Validate (input) password
This is a useful function if you need to validate a password (input). If you have a form and you need to check if the username, which is registering, entered a valid password (without illegal characters) then this would help you to do it. Only letters, numbers and underscores are accepted.
Read moreSimple Age Calculator
This is a simple php function that calculates the age of someone, in years.
Read more