I have a file that i have inserting data into a mySQL Database i want to insert an UPDATE sql query in the script
i have something like this
$cols = "col1, col2, col3, col4)";
list($value1, $value2, $value3, $value4) = $items;
array_push($posted_content, $items);
vals = "";
vals .= "$value1 ,"
vals .= "$value2 ,"
vals .= "$value3 ,"
vals .= "$value4 ,"
$sql = "INSERT INTO table ($cols) VALUES ($vals)";
I want to put an If/Else statement if it exist. and will update the record.
I have tried something like this but wont work
$sql = "UPDATE table SET ($cols) VALUES ($vals) WHERE col1 =" . $value1;