我很困惑......我遇到了一个让我发疯的小问题。我的数组中有数组,我想将其插入到 SQL 表中。我的问题是我不知道如何在数组中插入数组......
数组: Array ( [1] => Array ( [diploma] => Master [institute] => IAE ) [2] => Array ( [diploma] => Bachelor [institute] => University ) )
欢迎任何建议:)非常感谢法国!
<input id="mytext-{cid}" type="text" name="training[{cid}][diploma]" placeholder="Diplôme" value="">
<input name="training[{cid}][institut]" placeholder="Institut">
try
{
$pdo = new PDO('mysql:host='.$host.';dbname='.$bd, $login, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
}
catch (Exception $e) //Le catch est chargé d’intercepter une éventuelle erreur
{
die ($e->getMessage());
}
global $pdo;
// INSERT MySQL
if (empty($_POST['training'])){
}
else {
$sql = "INSERT INTO user_resume (Diplome,Institut) VALUES (?,?)";
$stmt= $pdo->prepare($sql);
$stmt->execute($_POST['training']);
}
catspeake