2011-03-18 97 views
1

你好我正在使用datagrid。我已經完成了分頁和編輯現在我得到刪除的問題。在分頁時,它會自動在一頁中製作頁面。這裏是從哪兒我打電話php datagrid刪除頁面問題

$deletetUrl = "admin.php?page=delete_user&id=".$data["user_id"]."&pageid=".$pageNumber." ";    
$delete = "<a href='".$deletetUrl."'><img src='".$assets."edit-delete.png' alt='Delete' title='Delete' border='0' height='16' width='16'></a>"; 

其到這個頁面的代碼

 <?php   
      echo $query = "Delete from user where user_id=$_GET[id]"; 
      $result = mysql_query($query); 


      ?> 

     <script type="text/javascript"> 
     window.location="admin.php?page=view_user&pageid=<?php echo urlencode($_GET[pageid]); ?>" 
     </script> 

它完全刪除,並用這個javascript函數它可以追溯到它去第1頁的記錄,雖然我有從其他頁面刪除。請讓我怎麼去同一頁,從這裏刪除了我的記錄或者任何人都可以建議可以拿出解決方案的小ajax功能

回答

1
<?php   
    /* You should sanitize the $_GET['id'] input & restrict access to this page as 
    your vulnerable to sql injection as posting ?id=1 would most likely delete your admin user 
    */ 
    $query = "Delete from user where user_id=$_GET[id]"; 
    $result = mysql_query($query); 
    header('Location: admin.php?pageid='.$_REQUEST['pageid']); 

    ?>