Greetings to all, please help to finish the code, everything basically works only when you select a line in the table for further deletion, the "delete marked" button does not work, the page reloads, and the records remain in place.

<?php // соединение с базой данных require_once 'connect.php'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru"> <head> <title>Админ-панель</title> <meta content="text/html; charset=windows-1251" http-equiv="Content-Type" /> <title>Таблица 2000 строк с фильтрацией</title> <link rel='stylesheet' href='classes.css' type='text/css'> <link rel='stylesheet' href='tabsort1.css' type='text/css'> <script type='text/javascript'>var d0 = new Date()</script> <script type='text/javascript' src='tabtools1.js'></script> <script type='text/javascript' src='tabsort1.js'></script> </head> <?php // Отображаем результаты echo '<p>Таблицы, имеющиеся в базе данных: </p>'; echo "<table class='sortable' id='t' border=1 >"; echo "<col class='id'><col class='name'><col class='width'><col class='profile'><col class='radius'><col class='price'><col class='prices'><col class='sellers'><col class='season'><col class='status'>"; echo "<thead>"; echo "<tr>"; echo "<th axis='num'>ID&nbsp;</th>"; echo "<th>Улица&nbsp;</th>"; echo "<th axis='num:alt'>Width&nbsp;</th>"; echo "<th axis='num:alt'>Квартира&nbsp;</th>"; echo "<th axis='num:alt'>Radius&nbsp;</th>"; echo "<th axis='num'>Price&nbsp;</th>"; echo "<th>Prices&nbsp;</th>"; echo "<th axis='num'>Sellers&nbsp;</th>"; echo "<th>Season&nbsp;</th>"; echo "<th axis='num:alt'>Status&nbsp;</th>"; echo "</tr>"; echo "</thead>"; //Удаляем, если что if (isset($_GET['del'])) { $result = mysql_query('DELETE FROM `user_profiles` WHERE `ID` = "'.$_GET['del'].'"'); if ($result) { echo "<p>Товар удален.</p>"; } else { echo "<p>Произошла ошибка.</p>"; } } //Получаем данные echo '<form action="'.$_SERVER['PHP_SELF'].'" method="GET">'; $result = mysql_query("SELECT * FROM `user_profiles`") or trigger_error(mysql_error()); while($row = mysql_fetch_array($result)){ foreach($row AS $key => $value) { $row[$key] = stripslashes($value); } echo "<tr>"; echo "<td valign='top'>" .$row['id']. "</td>"; echo "<td axis='num' valign='top'>" .$row['mes']. "</td>"; echo "<td valign='top'>" .$row['dom']. "</td>"; echo "<td valign='top'>" .$row['kvar']. "</td>"; echo "<td valign='top'>" .$row['password']. "</td>"; echo "<td valign='top'>" .$row['phon']. "</td>"; echo "<td valign='top'>" .$row['van1']. "</td>"; echo "<td valign='top'>" .$row['van2']. "</td>"; echo "<td valign='top'><a href=?del={$row['id']}>Delete</a></td> "; echo '<td><input type="checkbox" name="row[]" value="'.$row['id'].'" /></td>'; echo "</tr>"; } echo "</table>"; echo '<input type="submit" name="submitForm" value="Удалить отмеченные" />'; if ( isset ( $_GET['row'] ) ) { print_r($_GET) ; $ids = implode( ',', $_GET['row'] ); $query = 'DELETE FROM items WHERE id IN ('.$ids.')'; mysql_query( $query ); header( 'Location: '.$_SERVER['PHP_SELF'] ); } ?> 

enter image description here

  • And what does var_dump ($ _GET ['del']) give? - labris
  • labris And where did you find such a string? I don't see. - Stas Tamkov
  • labris Or did you mean that I did not correctly write the code in this place? Generally, one entry is deleted without problems, in the place you are talking about, and when you check and click the "Delete marked" button, it gives me such comments - Array ( [submitForm] => Удалить отмеченные ) , but that I am not I do not understand at all ... - Stas Tamkov
  • I meant that in order to check what the $ _GET ['del'] variable produces, you need to output it via var_dump ($ _GET ['del']). That is, put this line before if (isset ($ _ GET ['del'])) and see what comes up. - labris
  • you should write headers already sent down below. 1) Do not delete via GET, this type of request exists for receiving data, for changing / deleting there is POST and other less used ones. 2) You cannot send a header after what is already displayed, your header-location will not work at the end. 3) do not use the mysql extension, it is outdated 4) use templating engines, separate logic and representation - teran

0