PHP & MySQL - How to amend lower/higher case?

Discussion in 'PHP' started by HolmesAndHarris, Jul 2, 2008.

  1. #1
    Hi Guys,

    I hope you can help me out on this one...

    At present, I have a mysql table with rows that contain FirstName and Surname.

    Example of current table

    john, Doe
    Jane, Smith
    jason, roberts
    Andrew, smith

    I'm wanting to get it to update all mysql rows so that the formatting is correct (I.e. Firstname Surname - Cap at start of each, and rest lower case).

    Can anyone tell me if this is possible?

    Cheers
    Chris
     
    HolmesAndHarris, Jul 2, 2008 IP
  2. scc

    scc Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Check "PHP referance" (in chm format, you can take it from php.net), "functions" section "string functions".
     
    scc, Jul 2, 2008 IP
  3. David Pankhurst

    David Pankhurst Member

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    I haven't checked the code, but you should be able to do this one time to set all of them:

    UPDATE YOURTABLENAME SET 'FirstName'=CONCAT(UCASE(MID(FirstName,1,1)),LCASE(MID(FirstName,2))), 'Surname'=CONCAT(UCASE(MID(Surname,1,1)),LCASE(MID(Surname,2)))

    before you try it, please backup your db first....
     
    David Pankhurst, Jul 2, 2008 IP