hi all, I managed to get this little snippet working, it's pretty useful if you have long forms to be inserted into a database.
if ( ! empty ( $_POST ) ){
array_pop($_POST);
foreach($_POST as $key => $val){
$columns .= addslashes($key) . ", ";
$values .= "'" . addslashes($val) . "', ";
}
$values = substr_replace($values, "", -2);
$columns = substr_replace($columns, "", -2);
$sql = "INSERT INTO table ($columns) VALUES ($values)";
echo $sql;
$results = odbc_exec($conn, $sql);
if ($results){
echo "Query Executed";
}else {
echo "Query failed " .odbc_error();
}
}
Not the most secure in the world but, speeds up collecting data from large forms.