Q:

Insert multiple rows from one AJAX POST into database using PHP?

Post header:
seasonString: Sommer,Hebst,Frühling,Winter
holidaywishString: 3,4,7,8                          

PHP:
//Insert Seasons data
$sqli="INSERT INTO seasons(season)VALUES('{$mysqli->real_escape_string($_POST['seasonString'])}')";
$insert=$mysqli->query($sql);
// $userID = mysqli_insert_id($mysqli);
//Insert Desires data
$sqli="INSERT INTO desires(desires)VALUES('{$mysqli->real_escape_string($_POST['holidaywishString'])}')";
$insert=$mysqli->query($sql);
// $userID = mysqli_insert_id($mysqli);

In this case the data is inserted into my database table tbl_season on one column:
Sommer, Hebst, Frühling, Winter
holidaywishString:3, 4, 7, 8    

But I want it to be this way:
tbl_season;
id    season
-1    Sommer                        
-1    Hebst
-2    winter
-3    hebst

How can I achieve that?

A:

$arrSeason = explode(',', $_POST['seasonString']);
    foreach($arrSeason  as $season ){
        $sqlSeason = "INSERT INTO seasons(season,iduserinfo)VALUES('".$mysqli->real_escape_string($season)."','$userID')";
        $mysqli->query($sqlSeason);
    }
/problem solved Thanx a lot

