Answers for "update using array"

0

update using array

/* function to build SQL UPDATE string */
function build_sql_update($table, $data, $where)
{
    $cols = array();
 
    foreach($data as $key=>$val) {
        $cols[] = "$key = '$val'";
    }
    $sql = "UPDATE $table SET " . implode(', ', $cols) . " WHERE $where";
 
    return($sql);
}
Posted by: Guest on October-11-2021

Browse Popular Code Answers by Language