php剔除记录

php删除记录
<form id="form3" name="form3" method="post" action="">
  <p>
  <label for="id2">删除序号为</label>
  <input name="id2" type="text" id="id2" size="10" />
  的记录
  </p>
  <p>
  <input type="submit" name="del" id="del" value="删除" />
  </p>
  </form>

=============================================

我想删除指定ID号的记录,数据记录主键为“id”,后面的代码怎么写,我写的代码老是删不掉,麻烦大虾们帮个忙。

------解决方案--------------------
PHP code

<?php
#test.php
if(isset($_POST['id2'])){
    $sql="delete from table where id=".trim($_POST['id2']);
    $res = mysql_query($sql);
    if(!$res)
        die("SQL:{$sql}<br>Error:".mysql_error());
    if(mysql_affected_rows() > 0){
        echo "删除成功!<br>";
    }else{
        echo "查询失败<br>Error:".mysql_error();
    }
}
?>
<form id="form3" name="form3" method="post" action="test.php">
  <p>
  <label for="id2">删除序号为</label>
  <input name="id2" type="text" id="id2" size="10" value="3" />
  的记录
  </p>
  <p>
  <input type="submit" name="del" id="del" value="删除" />
  </p>
</form>