vendredi 30 janvier 2015

Insert array value into database

I have an array of checkboxes whose value I want to insert into a database. The checkbox declaration is like this:



echo '<td><input type="checkbox" name="check_list[]"
onClick="toggle(this, '.$x.')" /> All</td>';


And here I try to insert it (together with other variables, that doesnt really matter). So, the other variables are inserted, while this one isnt.



<?php
ob_start(); //eliminates buffer collisions
require_once('connect_db.php');
$id = time(); //creates a unique id using the unix time
$result = pg_query(connect(), "INSERT INTO lecturer VALUES ($id, '$_POST[name]','$_POST[surname]','$_POST[department]')");

$check = $_POST['check_list[0]'];
$availability = pg_query(connect(), "update lecturer set monday='$check'");

?>


What is wrong with my syntax? Cause all the values are inserted, besides that of the checkbox.





Aucun commentaire:

Enregistrer un commentaire