Brent Baisley wrote:
> foreach($insert as $table => $fields) {
> $fieldList = array_keys($fields);
> $fieldNames = implode(',', $fieldList);
> $fieldValues = '"'.implode('","', $fields).'"';
> echo 'insert into '.$table.' ('.$fieldNames.') values
> ('.$fieldValues.')';
> }
>
A, I was wondering why your variable was named insert.
Anyway, that's easy too.
foreach($insert as $table => $fields) {
$fieldList = array_keys($fields);
$fieldNames = implode(',', $fieldList);
$fieldValues = '"'.implode('","', $fields).'"';
echo 'insert into '.$table.' ('.$fieldNames.') va
Ok - looking at what you did I cant see any diference apart from turning a
serious updated into a single update. This is usefull if I want to do an update
but I actualy want an insert (the update was just used for this example).
I actualy want to do an insert so i'me thinking the following would
You've created a 2x2 array, not a 1x4, which might be confusing you:
tab2 ["fields1"] ["fields5"]
tab1 ["fields2"] ["fields7"]
You almost have it, you just need to set your loop up to handle
unlimited field/value pairs in your array.
One option is to structure your loop like this:
foreach ($inse
4 matches
Mail list logo