/    Sign up×
Community /Pin to ProfileBookmark

Converting one value in array to UPPER case

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.

[code]

$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;
}

[/code]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@pyroOct 29.2003 — Yep, just use [url=http://us2.php.net/manual/en/function.strtoupper.php]strtoupper()[/url].
Copy linkTweet thisAlerts:
@sharapovauthorOct 29.2003 — pyro,

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

Thanks.
Copy linkTweet thisAlerts:
@pyroOct 29.2003 — You just need to pull out the value you need. Perhaps something along these lines (simplified):

[code=php]for ($i=0; $i<$somenum; $i++) {
if ($i == 0) {
$val .= strtoupper($array[$i]);
}
}[/code]
Copy linkTweet thisAlerts:
@sharapovauthorOct 29.2003 — pyro,

Thanks for the tip. I figured it out!
Copy linkTweet thisAlerts:
@pyroOct 30.2003 — You bet... ?
×

Success!

Help @sharapov spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...