note 54554 added to function.strtoupper
| From: | jeremy at opendoorvisions dot com | Date: | Thu, 07 Jul 2005 18:01:54 +0000 |
| Subject: | note 54554 added to function.strtoupper | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-91605@lists.php.net to get a copy of this message | ||
created this to convert a clients inventory system
to all uppercase when the db was already created.
<?php
/*
Author: Jeremy Hoffman:
Opendoor Visions www.opendoorvisions.com
June 2005
*/
//this require is the connection to your database
require("connectdb.inc");
// check for connection ---------------
if(!$db){
echo 'Cannot Connect To Database';
}
else{
mysql_select_db('databasename',$db);
}
query = 'SELECT * FROM customers';
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for($j = 0; $j < $num_results; $j++){
// replace the names next to description with your database headings
$description = mysql_fetch_array($result);
$firstname = $description['customers_firstname'];
$lastname = $description['customers_lastname'];
$id = $description['customers_id'];
// Convert the strings to Uppercase
$firstname = strtoupper($firstname);
$lastname = strtoupper($lastname);
// change the DB!
$query='UPDATE customers
SET customers_lastname="'.$lastname.'",
customers_firstname="'.$firstname.'"
WHERE customers_id="'.$id.'"';
mysql_query($query);
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.strtoupper.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54554
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54554&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54554&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54554&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54554&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54554&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54554&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54554&report=yes
Search -- http://master.php.net/manage/user-notes.php