2011-11-08 3 views
0

나는 PHP에서이 코드를 작성 했으므로 삭제 열의 "delete checkbox"가 선택된 데이터베이스에서 행을 삭제해야합니다. 그리고 "verify"값 (1 또는 0)을 데이터베이스에 보내려고합니다. 하지만 SQL 명령을 삭제 알고 행을 확인하고 $_POST[$id])를 사용하여 값을 얻을 수 없기 때문에 내가 ("확인"열의 값을 얻는 방법을 모르는하지 않습니다.체크 표시된 열을 삭제하고 라디오 버튼의 값을 보내는 방법은 무엇입니까?

<?php 
    echo "<form action=\"index.php?go=save\" method=\"POST\"> 
     <table width=\"335\" border=\"1\"> 
     <tr> 
     <th width=\"19\" scope=\"col\">ID</th> 
     <th width=\"31\" scope=\"col\">Title</th> 
     <th width=\"33\" scope=\"col\">URL</th> 
     <th width=\"52\" scope=\"col\">Visitors</th> 
     <th width=\"28\" scope=\"col\">Hits</th> 
     <th width=\"52\" scope=\"col\">Verify</th> 
     <th width=\"27\" scope=\"col\">Edit</th> 
     <th width=\"41\" scope=\"col\">Delete</th> 
     </tr>"; 
    $query = mysql_query("SELECT * FROM posts ORDER BY visitors DESC"); 
    while($write = mysql_fetch_array($query)) { 
     $id  = $write['id']; 
     $title  = $write['title']; 
     $url  = $write['url']; 
     $visitors = $write['visitors']; 
     $hits  = $write['hits']; 
    echo" 
     <tr> 
     <td>$id</td> 
     <td>$title</td> 
     <td>$url</td> 
     <td>$visitors</td> 
     <td>$hits</td> 
     <td> 
     <input type=\"radio\" name=\"$id\" value=\"1\" />Yes 
     <input type=\"radio\" name=\"$id\" value=\"0\" />No 
     </td> 
     <td><a href=\"index.php?go=edit\">Edit</a></td> 
     <td> 
      <input type=\"checkbox\" name=\"$id\" /> 
     </td> 
     </tr>"; 
    } 
    echo "</table> 
     <input type=\"submit\" value=\"Save\" /> 
     </form> "; 
    ?> 

하시기 바랍니다, .. 확인

<input type=\"checkbox\" name=\"delete[]\" value=\"$id\" /> 

및 삭제 : 내가이 문제를 해결하는 데 도움이 당신이 다른 변종을 알고 있다면, 그것을 적어주세요

답변

0

삭제 열

foreach($_POST['delete'] as $id_to_delete) { 
    mysql_query("DELETE FROM posts WHERE ID=".$id_to_delete) 
} 
관련 문제