dpkt17803 2010-08-28 14:44
浏览 17

如果$ _POST ['value']在数据库中,那么弹出警报的最佳方法是什么?

I'm making a script where a user enters a value and clicks Submit. However, I want it to pop up an alert asking if they are sure, if the value is already in the database. I was thinking of doing this with AJAX, but a friend of mine is a jQuery fanatic and told me to go with that instead.

What would be better for this task, and how would I go about doing it in the respective choice? I found a tutorial on Tizag that explained how to do something similar, but they said that a submit button wasn't needed, and thus didn't include anything about it.

EDIT: Some code was requested, here it is:

if (isset($_POST['submit'])){
    $sql = "SELECT * FROM table WHERE column='$data'";
    $query = mysql_query($sql) or die(mysql_error());
    $number = mysql_num_rows($query);
    if ($number > 0){
        //needs to pop up
        //if user selects yes {
            //continue
        //}else{
            //break
        //}
    }
}

Something along these lines, although I know I need to start the AJAX prior to this code or it will have to reload the page.

  • 写回答

2条回答 默认 最新

  • dongxindu8753 2010-08-28 14:46
    关注

    Ajax is something you can implement with either vanilla javascript or with jQuery, the jQuery makes it really easy though.

    Have a look at:

    jQuery Ajax Tutorial

    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答