Here's what I have:
Code: Select all
<?php
foreach ($formarray as $key => $value) {
$output = "$key = '$value',";
echo $output;
}
?>Any ideas?
Moderator: General Moderators
Code: Select all
<?php
foreach ($formarray as $key => $value) {
$output = "$key = '$value',";
echo $output;
}
?>Code: Select all
<?php
# Using SET syntax (which is more common for UPDATE's than inserts
$comma = '';
$sql = 'INSERT INTO tablename SET ';
foreach ($formarray as $key => $value) {
$sql .= $comma ." $key = '".mysql_escape_string($value)."' ";
if (!$comma) $comma = ','; # Perhaps this is more efficient by just skipping the if (?)
}
?>