删除多行来自php mysql数据库和文件系统使用复选框

时间:2014-03-11 13:36:52

标签: php html mysql

我一直在阅读这个问题的多种解决方案,并将自己的问题整合在一起。我遇到的唯一问题是它没有从文件系统或数据库中删除。

以下是我所拥有的片段:

$jobs = DB::ex($q);

 if ($jobs[0]['job_id']) {

 echo '<table width="100%" cellpadding="6" cellspacing="6" style="font-size:9px;">';
 if ($user->properties['user_level'] == 1) {

    echo '<tr valign="middle"><td><input type="button" value="Delete" onclick="deleteRow('. $jobs[$i]['job_id'] .')" /></td></tr>'; 

 }
 =======================================
 function deleteRow(jid) {
    if (confirm("Are you sure you would like to delete these record?")) {
        alert(jid);
        window.location = '<? echo $_SERVER['REQUEST_URI']; ?>&delete=' + jid;
    }
  }
 ========================================================

if ($_GET['delete'] && (int)$_GET['delete'] > 0) {

    $_jid = (int)$_GET[delete];     


    foreach($_jid as $value){
        echo $value;
        DB::ex('Delete from jobs where job_id='.$value);
        @shell_exec("rm -rf ".PRIVATE_DIR."jobs/".$value."/");        
    }
    header("Location: ".preg_replace("/\&delete\=[0-9]*/", "", $_SERVER['REQUEST_URI']));
    }

我可以请一点指示...我希望我走在正确的轨道上。

1 个答案:

答案 0 :(得分:0)

window.location = '<?php echo $_SERVER['REQUEST_URI']; ?>&delete=' + jid;
你错过了一个&#34; php&#34;在开始标记