Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $values = []; $_POST = ['a' => 1, 'b' => 2]; // REMOVE UNNEEDED FIELDS SPECIFIED IN $REMOVEFIELDS VARIABLE if (isset($RemoveFields) && !is_array($RemoveFields)) $RemoveFields = array($RemoveFields); $values = (isset($RemoveFields)) ? array_diff_key($_POST, array_flip($RemoveFields)) : $_POST; foreach ($values as $key => $value) : $values[$key] = (is_numeric($value)) ? $values[$key] : str_replace(",", "&#44;", htmlentities($value)); endforeach; echo $sqlSubmit = "UPDATE `$TableName` SET ".implode(", ", array_map(function($value){ return "`$value` = ?"; }, array_keys($values))) . " WHERE `ID` = ?"; var_dump($values); #$stmt = $mysql->prepare($sqlSubmit); #$stmt->execute($values); #return $stmt->affected_rows; 3$stmt->close();
Copy Clear