我遇到了一个问题,我在 while 循环中有表单,我正在尝试使用 JQuery 提交它们以从 mysql 数据库中删除条目。问题是当我按下删除时,无论我按下哪个删除按钮,它都会发送相同的 ID。
$("#deletePost").validate({
        debug: false,
        rules: {        
        },
        //If the rules are not met, the following messages are displayed beside the input field.
        messages: {
        },
        // do other stuff for a valid form
        submitHandler: function(form) {
            $.post('bin/Profile.php', $("#deletePost").serialize(), function(data) {
                $('#ProfileWall').prepend( data );
            });
        }
    });
}); 
            <div id='ProfileWall'>
            <?php 
                $WallRequest = mysql_query("SELECT * from WallPost where WallOf = '".$sn."' group by TimeAndDate DESC;")or die(mysql_error());
                while($WallInformation = mysql_fetch_array($WallRequest))
                {
                    $PostedBy =  mysql_fetch_array(mysql_query("SELECT * from members where ServiceNumber = '".$WallInformation['PostedBy']."';")); 
            ?>      
                        <div id = "post_<?php echo $WallInformation["id"]; ?>" >    
                        <form name = 'deletePost' id = 'deletePost' method = 'post'>
                        <table border = '0' width = '550' height = '60' valign = 'top'    align = 'center'>
                            <tr valign = 'center'>
                                <td width = '10' valign = 'center'>
                                    <input type = "hidden" name = "id" id = "id" value = "<?php echo $WallInformation['id']; ?>" >
                                    <input type = "hidden" name = "sn" id = "sn" value = "<?php echo $sn; ?>" >
                                    <input type = "submit" name="Delete" id = "Delete" value="Delete" class="delete" />
                                </td>
                            </tr>
                        </table>
                        </form>
                        </div>
          <?php } ?>
        </div>