Click to See Complete Forum and Search --> : Converting one value in array to UPPER case


sharapov
10-28-2003, 11:09 PM
I am collecting data from the form. Before I put collected data That I got from $_POST['array']) into a MySQL database I want to convert one of the values (let's say value 1 in the array) in the array to upper case. How can it be done?

Below is the snippet of my code that I use to put data into a dtabase.



$result=exequery("Select * from $tablename", $tablename, $dbname);

$flds = mysql_num_fields($result);
$qry=" ";
$query = "Insert into $tablename Values( ";
for ($x =0; $x < $flds; $x++){

if(is_array($array[$x])){
$mval="";
for($m=0; $m < count($array[$x]); $m++){
if($m+1 == count($array[$x])){
$mval.= AddSlashes($array[$x][$m]);

}else{
$mval.= AddSlashes($array[$x][$m]).",";
}
$fval = $mval;
}
}else{
$fval = AddSlashes($array[$x]);
}
$qry .= "'$fval'";
if ($x < $flds-1){
$qry.= ", ";
}
}
$query .= $qry.")";

$result=exequery($query, $tablename, $dbname);
if($result){
return $result;
}else{
return false;
}

pyro
10-29-2003, 07:25 AM
Yep, just use strtoupper() (http://us2.php.net/manual/en/function.strtoupper.php).

sharapov
10-29-2003, 01:18 PM
pyro,

Can you give me an example of how can I use this function in my scenario. I can't figure it out :(.

Thanks.

pyro
10-29-2003, 01:29 PM
You just need to pull out the value you need. Perhaps something along these lines (simplified):

for ($i=0; $i<$somenum; $i++) {
if ($i == 0) {
$val .= strtoupper($array[$i]);
}
}

sharapov
10-29-2003, 01:43 PM
pyro,

Thanks for the tip. I figured it out!

pyro
10-29-2003, 09:38 PM
You bet... :)