note 62596 added to function.mysql-fetch-assoc
| From: | paintedgauthier at gmail dot com | Date: | Sat, 04 Mar 2006 09:49:45 +0000 |
| Subject: | note 62596 added to function.mysql-fetch-assoc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104819@lists.php.net to get a copy of this message | ||
Sorry the last one i posted does a normal non-mysql array , this will work the magic on a assoc
array
<? function assoc_array_to_mysql() {
global $array;
$update = 'update player set ';
foreach($array as $key => $value) {
if ($i) { $update .= key($array);
$check = current($array);
if (isset($check)) {
$update .= '=\''.current($array).'\'';
} else { $update .= '=null'; }
} else { $key = key($array);
$current = current($array);
$end = "where $key = $current"; }
next($array);
$check = key($array);
if (isset($check)) {
if ($i) {$update .= ', '; }
} else {$update .= ' '.$end; }
$i++;
}
$result = mysql_query($update) or die(mysql_oops($update));
echo 'Updated';
} ?>
----
Server IP: 66.163.161.117
Probable Submitter: 65.189.222.1
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-assoc.php
Edit -- http://master.php.net/note/edit/62596
Del: integrated -- http://master.php.net/note/delete/62596/integrated
Del: useless -- http://master.php.net/note/delete/62596/useless
Del: bad code -- http://master.php.net/note/delete/62596/bad+code
Del: spam -- http://master.php.net/note/delete/62596/spam
Del: non-english -- http://master.php.net/note/delete/62596/non-english
Del: in docs -- http://master.php.net/note/delete/62596/in+docs
Del: other reasons-- http://master.php.net/note/delete/62596
Reject -- http://master.php.net/note/reject/62596
Search -- http://master.php.net/manage/user-notes.php