QA

Q&A

Q1:

Are there any other string functions that might be useful to me?

A1:

Yes. PHP has more than 60 string functions! You can read about them all in the PHP Manual online at http://www.php.net/manual/ref.strings.php.

Q2:

Can I use multiple functions in one statement, such as making a concatenated string all uppercase?

A2:

Sure just be mindful of your opening and closing parentheses. This example shows how to uppercase the concatenated first and last names from the master name table:

 mysql> SELECT UCASE(CONCAT_WS(' ', firstname, lastname)) FROM table_name; +--------------------------------------------+ | UCASE(CONCAT_WS(' ', firstname, lastname)) | +--------------------------------------------+ | JOHN SMITH                                 | | JANE SMITH                                 | | JIMBO JONES                                | | ANDY SMITH                                 | | CHRIS JONES                                | | ANNA BELL                                  | | JIMMY CARR                                 | | ALBERT SMITH                               | | JOHN DOE                                   | +--------------------------------------------+ 9 rows in set (0.00 sec) 

If you want to uppercase just the last name, use

 mysql> SELECT CONCAT_WS(' ', firstname, UCASE(lastname)) FROM master_name; +--------------------------------------------+ | CONCAT_WS(' ', firstname, UCASE(lastname)) | +--------------------------------------------+ | John SMITH                                 | | Jane SMITH                                 | | Jimbo JONES                                | | Andy SMITH                                 | | Chris JONES                                | | Anna BELL                                  | | Jimmy CARR                                 | | Albert SMITH                               | | John DOE                                   | +--------------------------------------------+ 9 rows in set (0.00 sec) 



Sams Teach Yourself PHP, MySQL and Apache in 24 Hours
Sams Teach Yourself PHP, MySQL and Apache in 24 Hours
ISBN: 067232489X
EAN: 2147483647
Year: 2005
Pages: 263

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net