Not sure if your looking for something like this but it was fun to create
<?php
$theStuff =array("Name" => "NewName", "Age" = > "15");
SetToDatabase($theStuff);
function SetToDatabase($theValue)
{
$table = "Test";
//Get list of Fields
$result = mysql_query("DESCRIBE `".$table."`");
$Data = array();
while ($row = mysql_fetch_array($result,MYSQL_NUM))
{
if( isset($theValue[$row[0]]) )
{
$Data[$row[0]] = $theValue[$row[0]];
}else{
$Data[$row[0]] = ""; //empty unset values
}
}
//Insert
// $Fields = array_keys($Data);
// $TheSet = "(".implode(",",$Fields).")";
// $TheValue = "(".implode(",",$Data).")";
// $SQLq = "INSERT INTO $table $TheSet VALUES $TheValue;"
//Update
$UPDATE = "UPDATE $table SET ";
foreach($Fields as $F => $V)
{
$UPDATE .= "`$F` = '$V'";
}
$SQLq = $UPDATE." " //<-- Where Blar
$result = mysql_query($SQLq );
}
?>
it probably has a few bugs as its written from the top of myhead but .. yeah