vendredi 2 décembre 2016

Php delete data from sqlite3 from select(from database) option in HTML

<div><select class="form-control"name="old_name"></select></div>
<div><input class="form-control" type="text" name="name" pattern="^[\w\- ]+$"/></div>

Noted that all items in select tag is generated from a javascript using "innerHTML" to update information from database.

Here are two element in HTML form using POST method. I want to replace the "old_name" with "name" in php. Here is my Php Code.

$orignal_name = $_POST['old_name'];
$q = $db->prepare("UPDATE categories SET name = ? WHERE name = ". $orignal_name);
return $q->execute(array($_POST['name']));

But it did not work. I try to echo "old_name" and the result is "NaN".




Aucun commentaire:

Enregistrer un commentaire