<?php
if (isset ($_POST['submit'])){
$name=$_POST['name'];
$sports=$_POST['sports'];
$data=array();
for($x=0,$l=count($sports); $x<$l; $x++){
$myArray = explode(',', $name[$x]);// you can use your own filter for names
foreach($myArray as $nm){
$data[]=array('name'=>$nm,'sports'=>$sports[$x]);
}
}
var_dump($data);
$query="INSERT INTO athletes (name, sports) VALUES ('".$data."')";
$result = mysqli_query($dbc, $query);
mysqli_free_result( $result);
}
?>
getting error array to string conversion. hot do i pass that in the database in separate rows. the output is working wonderfully when i dump just the way i want it but i cant seem to get it passed to the database.