Page 1 of 1

changing/replacing column values/styles

Posted: Wed Mar 19, 2003 3:35 am
by jarow
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

Posted: Wed Mar 19, 2003 7:02 am
by Johnm
If you do not want to have that done before the data is submitted, you could use a trigger in the db to do it.


John M

Posted: Wed Mar 19, 2003 8:22 am
by Rob the R
If you are using MySQL, you can make the first character of every value of that column with something like this:

Code: Select all

update tablename
set phylum = concat(upper(substring(phylum,1,1)),lower(substring(phylum,2));
But I would tend to leave the database values as they are, and just display the results as you want using PHP functions:

Code: Select all

$phylum = ucfirst(strtolower($phylum));
This way, you don't have to worry about continually cleaning the database values as new rows are created.

Posted: Fri Mar 21, 2003 2:20 am
by jarow
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

Posted: Fri Mar 21, 2003 8:19 am
by Rob the R
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.

Posted: Sun Mar 23, 2003 8:24 am
by jarow
Hi Rob,

So if option value of my list is <option value="<?php echo $row_rsphylum['phylum']?>" how would I exactly write the snippet and where would I place it?

Thanks

Jim

Posted: Mon Mar 24, 2003 8:22 am
by Rob the R
Try this:

Code: Select all

<option value="<?php echo ucfirst(strtolower($row_rsphylum&#1111;'phylum']))?>"