I have a column of data that is in all caps that I want to change to first letter capitalized only. what is the best way to do this.
column name = phylum
many thanks
changing/replacing column values/styles
Moderator: General Moderators
If you are using MySQL, you can make the first character of every value of that column with something like this:
But I would tend to leave the database values as they are, and just display the results as you want using PHP functions:
This way, you don't have to worry about continually cleaning the database values as new rows are created.
Code: Select all
update tablename
set phylum = concat(upper(substring(phylum,1,1)),lower(substring(phylum,2));Code: Select all
$phylum = ucfirst(strtolower($phylum));Thanks Rob,
I will take your advise about leaving the database alone and use the php statement instead, but here´s the problem.
my search fields are all dynamic list fields, which means the values the user selects come directly from the database. Is there a way of formatting this field so that when the database values are viewed in the list they basically conform to your suggestion:
$phylum = ucfirst(strtolower($phylum));
Thanks
Jim
I will take your advise about leaving the database alone and use the php statement instead, but here´s the problem.
my search fields are all dynamic list fields, which means the values the user selects come directly from the database. Is there a way of formatting this field so that when the database values are viewed in the list they basically conform to your suggestion:
$phylum = ucfirst(strtolower($phylum));
Thanks
Jim
How do they come directly from the database? If you are using PHP to read them from the database, just apply the code snippet we've talked about to each value from PHYLUM that is read from the database and before it is echo-ed to the HTML page.
If you have the code that creates the dynamic lists, I'm sure we can help you integrate the code into your programs.
If you have the code that creates the dynamic lists, I'm sure we can help you integrate the code into your programs.
Try this:
Code: Select all
<option value="<?php echo ucfirst(strtolower($row_rsphylumї'phylum']))?>"