Заполнение таблицы всеми записями не прошло

This commit is contained in:
Alexander 2024-08-07 12:29:05 +03:00
parent e8cf5efb3c
commit 9dffa8c5d9

View File

@ -57,7 +57,6 @@ $records = [];
$size = []; $size = [];
for ($i = 0; $i < $data['numberAll']->length; $i++) { for ($i = 0; $i < $data['numberAll']->length; $i++) {
$records[]['id'] = $i++;
// $sizeFederalBudget->update( // $sizeFederalBudget->update(
// $data['numberBF']->item($i)->textContent, // $data['numberBF']->item($i)->textContent,
// $data['numberBFF']->item($i)->textContent // $data['numberBFF']->item($i)->textContent
@ -95,7 +94,7 @@ for ($i = 0; $i < $data['numberAll']->length; $i++) {
} }
// echo "<pre>"; // echo "<pre>";
// print_r($records); // print_r($records[0]);
// echo "</pre>"; // echo "</pre>";
try { try {
@ -113,14 +112,12 @@ try {
$sql = " $sql = "
INSERT INSERT
INTO sveden_education_contingent ( INTO sveden_education_contingent (
id,
spec_code, spec_code,
spec_name, spec_name,
edu_level, edu_level,
edu_forms, edu_forms,
contingent contingent
) VALUES ( ) VALUES (
id,
:spec_code, :spec_code,
:spec_name, :spec_name,
:edu_level, :edu_level,
@ -129,17 +126,19 @@ $sql = "
) )
"; ";
echo "<pre>"; // Почему-то не сработала
print_r($records[0]); // foreach ($records as $record) {
echo "</pre>"; // $sth = $pdo->prepare($sql);
$sth = $pdo->prepare($sql); // try {
try { // $sth->execute($record);
$sth->execute($records[0]); // } catch (PDOException $e) {
} catch (PDOException $e) { // echo "Ошибка выполнения запроса:". $e->getMessage() . "";
echo "Ошибка выполнения запроса:". $e->getMessage() . ""; // }
} // }
$sql = 'SELECT * FROM sveden_education_contingent'; $sql = 'SELECT * FROM sveden_education_contingent';
foreach ($pdo->query($sql) as $row) { $array = $pdo->query($sql)->fetch(PDO::FETCH_ASSOC);
print_r($row);
} echo "<pre>";
print_r($array);
echo "</pre>";