Hello.

There is such code:

<?php $select_sql = "SELECT id, title, pages_title FROM ".$pages_table.""; $result = mysql_query($select_sql); $row = mysql_fetch_array($result); if(isset($_GET['del'])) { $query = "DELETE FROM ".$pages_table." WHERE `id` = '$id'";//Удаляем запись из БД mysql_query($query); } do { $pages = $row['id']; printf ("<tr class='tr'> <td id='p_num'>".$row['id']."</td> <td class='num_title1'><b>%s</b></td> <td class='num_title'> <b>%s</b> </td> <td class='num_title2'> <a href='?edit=".$row['id']."'>Редактировать</a><a href='?del=".$row['id']."'> Удалить</a> </td> </tr>",$row['title'], $row['pages_title'] ); } while($row = mysql_fetch_array($result)) ?> 

Please tell me how to make it delete the selected field, or if the link is clicked, the edit will go to the edit.php page with the selected id.

  • offtopic Long time not met adepts Popov)) Feels corporate identity. So add to the "Edit" link the path to this page: <a href='edit.php?edit=".$row['id'_alk."'> Edit </a> - Deonis
  • And why not removed? - Shahin
  • @Shahin, judging by your code, it can still be deleted, but only you do not see it, because you first select everything from the database, but only in the next step, if $ _GET ['del'] is present, delete one of the records. - Deonis
  • Well, maybe show me the right way, as I understand it, you can't see it. - Shahin
  • @Shahin, for starters, I would send you to undergo a rehabilitation course from the video lessons of Popov and his ilk. Unfortunately, today [this series of articles] [1] is already slightly out of date, and not everything needs to be taken from it. Although reading does not hurt, if you remember that to work with the database today is not recommended to use the extension mysql_ * , and to bet on MySQLi or PDO. Then you can return to this conversation. [1]: irbis-team.com/15/10/1 - Deonis

0