当我单击提交按钮时,除了将字符串的名称放在数组中之外,一切正常,我在每一行的列名下的行中都获得了名称“数组”。我整天都在更改代码,但无法弄清楚。请注意,我的数组里面有 130 多个字符串。
您可以在表中放置无限数量的行,对吗?关于如何解决名称问题并增加我的“限制 0、30”的任何建议?
这是我的代码:
曾是:
$array = ("","","");
$random = $array;
shuffle($random);
现在:
$array = ("","","");
而且还是不行。我还尝试使用 mysqli_stmt_send_long_data 进行试验,也无法使其正常工作。
<?php
include ('login-home.php');
$mysqli = new mysqli("", "", "", "");
if ($mysqli->connect_error) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_error . ") " . $mysqli->connect_error;
}
if (!$mysqli->query("INSERT INTO table(id, name) VALUES (id, '".$array."')")) {
echo "Multi-INSERT failed: (" . $mysqli->error . ") " . $mysqli->error;
}
/* Prepared statement, stage 2: bind and execute */
$id = 1;
if (!$stmt->bind_param("s", $id)) {
echo "Binding parameters failed: (" . $stmt->error . ") " . $stmt->error;
}
if (!$stmt->execute()) {
echo "Execute failed: (" . $stmt->error . ") " . $stmt->error;
}
for ($id; $id = $id+1; $id++) {
if (!$stmt->execute()) {
echo "Execute failed: (" . $stmt->error . ") " . $stmt->error;
}
}
$stmt->close();
?>