面對從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