Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Insert Data Into MySql Database Multiple Columns PHP Function

//Insert Data Into Multiple Columns
//$params= Array Value array('me_title' => $_POST['me_title'])
function insertData($table, $params)
{
    global $db;
    $columns = array_keys($params);
    $values = array_values($params);
    $sql = "INSERT INTO $table (" . implode(',', $columns) . ") VALUES ('" . implode("', '", $values) . "' )";
    $result = $db->query($sql);
    $insertId = $db->getInsertId();
    if ($result) {
        return $insertId;
    } else {
        return false;
    }
}
 
PREVIOUS NEXT
Tagged: #Insert #Data #Into #MySql #Database #Multiple #Columns #PHP #Function
ADD COMMENT
Topic
Name
9+5 =