I am trying to insert a $_POST array into a mysql database. The foreach works but not all values are inserted on the same row as you can see on the image below.
This is the foreach that i use to insert the array into the database:
if($_POST)
{
// con->insert is my mysql function to insert the values
foreach ($_POST as $key => $value) {
if($con->insert('test',$key, $value)==true)
{
echo 'Het werkt!!!';
}
}
}
EDIT This is the con function
public function insert($table,$row,$value) {
$query = mysqli_query($this->connect, "INSERT INTO `$table` (`$row`) VALUES ('$value')");
if ($query == true)
{
return true;
}
else{
return false;
}
}
I want to collect the variables from the post and then i want to put them in the database on the same row of the table.
How can i get the values on the same row? Thank in advance