F
F
fuzz1on2013-05-20 00:12:33
CMS
fuzz1on, 2013-05-20 00:12:33

Removing an entry from the database using a snippet (modx evo)

Greetings!
The question is this: in the snippet I display records from the database:

<?php
global $modx;

  $output = '';
  
  $result = $modx->db->query( 'SELECT id, fullname, subject FROM `orders`' );
  
  if( $modx->db->getRecordCount( $result ) >= 1 ) {
    $output .= '<ul>';
    while( $row = $modx->db->getRow( $result ) ) {
$output .= '<tr><td>'.$row['id'].'</td>';	
$output .= '<td>'.$row['fullname'].'</td>';   		
$output .= '<td>'.$row['subject'].'</td>';
$output .= '<td>'.$row['message'].'</td>';



$output .= '<a name="del"  href="?del='.$row['id'].'">Удалить</a></tr><br>';              

                           
    
}
    
               
  }
    else {
        $output = 'There are no records to show.';
    }
return $output;
?>


As you can see, the "Delete" link is also displayed.
How can you "catch" clicking on a link, and accordingly add a condition for deleting a record from the database? For some reason, the usual methods like isset($_GET) at the beginning of the snippet don't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nazar Mokrinsky, 2013-05-20
@nazarpc

isset($_GET['del']) or I didn't understand the question?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question