删除表格行

时间:2014-04-14 08:11:01

标签: javascript php mysql dom

今天我有一个关于如何删除一个桌面的问题。 我有一个表格,其中表格由foreach填充数据库中的数据。 在下面你可以看到foreach我用填充tablerow。

**我想通过选择按钮选择行并点击按钮'删除'该行将从数据库中删除。 **我希望有人可以帮助我

    $oSelect = new creatorwebsite();
    $cWebsites = creatorwebsite::get($oSelect);

foreach($cWebsites as $oWebsite)
    {
      $oTr2 = $oPage->createElement('tr');
      $oTr2->setAttribute('id', $oWebsite->getAttribute("website_id"));
        $oTd = $oPage->createElement('td');
          $oCheckbox = $oPage->createElement('input');
          $oCheckbox->setAttribute('type', 'checkbox');
          $oCheckbox->setAttribute('onclick','selectRow(this)');
          $oTd->appendChild($oCheckbox);
        $oTr2->appendChild($oTd);

        $oTd = $oPage->createElement('td', $oWebsite->getAttribute("server_name"));
        $oTr2->appendChild($oTd);
        $oTd = $oPage->createElement('td', $oWebsite->getAttribute("klantnaam"));
        $oTr2->appendChild($oTd);
        $oTd = $oPage->createElement('td', $oWebsite->getAttribute("startdatum")->format('Y-m-d'));
        $oTr2->appendChild($oTd);
        $oTd = $oPage->createElement('td', $oWebsite->getAttribute("quota"));
        $oTr2->appendChild($oTd);
        $oTd = $oPage->createElement('td', $oWebsite->getAttribute("status"));
        $oTr2->appendChild($oTd);
        $oTd = $oPage->createElement('td', '(Edit)');
        $oTd->setAttribute('class','editAction');
        $oTd->setAttribute('id','editButton');

        $oTr2->appendChild($oTd);
      $oTable->appendChild($oTr2);
    }

1 个答案:

答案 0 :(得分:0)

尝试ajax

  

$(document).ready(function(){

     

var id = $(“your_id”)。val();

     

$( “your_button”)。单击(函数(){

     
    

$。AJAX({

        type : "POST",
       url  : "delete.php",
       data : "id=" + id,
       error : function(){                
  
       },
       success : function(response){
  if(response == 'success'){
      location.reload();  
   }      
       }
   });
     
});
         

});

         

delete.php     建立你的数据库连接和     在此页面中执行删除过程并回显结果“成功或失败”。

  
相关问题