Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Changing the CASE of letters in Output

Posted on 2011-03-23
7
Medium Priority
?
290 Views
Last Modified: 2013-12-13
Hello Folks,

I would like to change the upper case of certain letters of the output from a certain column in a table..

e.g 1 here making the first letter in the output in Caps and the rest in all lowercase letters

before:
select , description, price from tbl_name
output SONY BLU-RAY INTERNAL DRIVE SATA (BLACK), $9.99

after:
select , description, price from tbl_name
output Sony blu-ray internal drive(black), $9.99


e.g 2 here making the first letter of every word in the output in Caps and the rest in all lowercase letters

before:
select , description, price from tbl_name
output SONY BLU-RAY INTERNAL DRIVE SATA (BLACK), $9.99

after:
select , description, price from tbl_name
output Sony Blu-ray Internal Drive(Black), $9.99


thanks in advance
0
Comment
Question by:Eaddy Barnes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 14

Expert Comment

by:Scott Madeira
ID: 35201805
you can do this for example 1:

$string = ucfirst(strtolower($string));

example two you could use:

$string = ucwords(strtolower($string));

May be some issues with the words inside (), though.  You will need to play with it.
0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 35201807
Hi,


example 1:
$mystring = "HELLO HOW ARE YOU TODAY";
$mystring = ucfirst(strtolower($mystring));

example 2:
$mystring = "HELLO HOW ARE YOU TODAY";
$mystring = ucwords($mystring);
0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 35201812
lol, beat me to it smadeira... :P

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 11

Author Comment

by:Eaddy Barnes
ID: 35203982
hey guys i'm not using php at all for the output only mysql queries.
0
 
LVL 41

Accepted Solution

by:
Sharath earned 2000 total points
ID: 35204103
To get the first output, try like this.
SELECT CONCAT(UPPER(SUBSTRING(description,1,1)),LOWER(SUBSTRING(description,2))) AS description,
       price 
  FROM tbl_name

Open in new window

0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 35204797
Why is it in the PHP zone then ? You are using PHP, there has to be some layer between the database and the page. And the easiest way to do what you want is to present data like jrm213jrm213 did.
0
 
LVL 11

Author Comment

by:Eaddy Barnes
ID: 35207526
It being in PHP Zone was my error..
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question