面对从 MySQL 堡垒中清除多行的任务,您已经在编码智慧的深处寻求启蒙。在着手进行数据清理工作时,您似乎遇到了难以逾越的障碍。
您编写的代码虽然意图勇敢,但未能执行其行消灭的预期目的。决心克服这个障碍,您通过向受人尊敬的编码社区展示您的代码来寻求指导:
// PHP witchcraft to connect to MySQL
$dbc = mysqli_connect('localhost', 'root', 'admin', 'sample') or die('MySQL is out to get you!');
$query = "select * from links ORDER BY link_id";
$result = mysqli_query($dbc, $query) or die('Whoops! Query went awry!');
$count = mysqli_num_rows($result);
// Assemble your army of checkboxes
while ($row = mysqli_fetch_array($result)) {
echo
$row[link_id]
$row[link_name]
$row[link_url]
HTML;
}
// The arsenal of deletion awaits your command
if (isset($_POST['delete'])) {
// Retrieve your checked victims
$checkbox = $_POST['checkbox'];
// Summon the wrath of deletion upon each victim
foreach ($checkbox as $del_id) {
$sql = "DELETE FROM links WHERE link_id='$del_id'";
// Unleash the purging power!
$result = mysqli_query($dbc, $sql);
}
// If successful, redirect to the crime scene
if ($result) {
echo '';
}
}
唉,由于一些关键的疏忽,您的代码出现了问题:
通过这些纠正,您的代码将像数字巫师一样消除行。带着新的信心开始您的数据清理任务!
免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3