dsam70528 2013-06-16 17:22
浏览 67
已采纳

使用按钮运行MySQL删除查询

I have a user account page which runs the following loop of code:

<?php foreach ( $cv_specs as $cv_spec ) : ?>
<div id="document_summary_container">
    <div id="document_text_container">
        <div id="document_id">ID: MFI<?php echo $cv_spec->id; ?></div>
        <div id="document_title"><?php echo $cv_spec->file_mask; ?></div>
        <div id="document_version">V1.<?php echo $doc_row['version_of']; ?></div>
        <div id="document_specifics_container"><?php if ($doc_row['load_date']) echo "Document Submitted&nbsp;".$doc_row['load_date']."<br />";?><?php if ($doc_row['review_complete_date']) echo "Document Reviewed&nbsp;".$doc_row['review_complete_date']."<br />";?><?php if (($doc_row['review_complete_date']) !== "") echo "Document seen by&nbsp;".$doc_row['num_reviews']."&nbsp;expert";?><?php if (($doc_row['num_reviews']) != 1) echo "s";?> 
        </div>
    </div>
    <div id="document_image_container">
    <img src="images/system/a4_logo.jpg" width="134" height="190" /></div>
    <div id="document_buttons_container"></div>
</div><!--document_summary_container-->
<?php endforeach?>

In effect this generates a summary of files that the logged in user has uploaded which are reviewed by other users of the site.

I want to add a button for each document listing which when clicked would run a number of queries to delete all the information relevant to that document from the database. Without wanting to sound vague, I'm really not sure of the best way to go about it. I thought about using $_GET actions on the button to invoke a stored procedure based on the parameters submitted but thought this would leave it massively open to user manipulation. Any thoughts appreciated.

  • 写回答

1条回答 默认 最新

  • doubeng9407 2013-06-16 17:41
    关注

    Generally you should use a post request for this so people can't trick you into clicking on links that will send a delete request.

    Make a button using just about any HTML element then, using jquery, put a .click event on it that sends the delete request through the POST method.

    <span id='delete' style='color:blue;cursor:pointer;'>delete</span>
    <script>
    $("#delete").click(function(){
        $.post('/delete_path',{delete_id:1},function(){
            alert('deleted!');
        },'text');
    }};
    </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!