eits Posted September 11, 2007 Share Posted September 11, 2007 Hello! I was wondering if it is possible to do the following with a PHP script (I am new to PHP). I have a database with customer information but all the company names are in capitals. Is it easy to somehow convert all of these to lowercase but with a capitalised letter for the first letter of each word. so 'BOBBYS BITS AND PIECES' becomes 'Bobbys Bits And Pieces'. Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/68827-make-all-database-rows-lowercase-with-a-capital/ Share on other sites More sharing options...
MadTechie Posted September 11, 2007 Share Posted September 11, 2007 use ucfirst ucfirst(strtolower("BOBBYS BITS AND PIECES")); Link to comment https://forums.phpfreaks.com/topic/68827-make-all-database-rows-lowercase-with-a-capital/#findComment-345931 Share on other sites More sharing options...
xyn Posted September 11, 2007 Share Posted September 11, 2007 a capitalised letter for the first letter of each word. so 'BOBBYS BITS AND PIECES' becomes 'Bobbys Bits And Pieces'. close.. but ucwords("BOBBYS BITS AND PIECES"); Link to comment https://forums.phpfreaks.com/topic/68827-make-all-database-rows-lowercase-with-a-capital/#findComment-345938 Share on other sites More sharing options...
eits Posted September 11, 2007 Author Share Posted September 11, 2007 Great - thats something I havent stumbled across yet! How would I make it replace all of the MySql entries at once though? Link to comment https://forums.phpfreaks.com/topic/68827-make-all-database-rows-lowercase-with-a-capital/#findComment-345959 Share on other sites More sharing options...
MadTechie Posted September 11, 2007 Share Posted September 11, 2007 no SQL statements to update them with that!.. your need to create a script that loop throught each record and update it. basic idea 1. connection #1, select * 2. loop though each records (start) 3. $data = ucwords(strtolower($c1row['data'])); 4. connection #2 update table set data='$data' where ID={$c1row['id']} 5. end loop sorry (i'm at work so had to be quick ) Link to comment https://forums.phpfreaks.com/topic/68827-make-all-database-rows-lowercase-with-a-capital/#findComment-345967 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.