douliao8760 2013-08-21 04:38
浏览 117

如何使用php和javascript从mysql中删除行

I am trying to delete the entire row using the php code.

But before that my page has a multiple rows ended with radio button before clicking delete button we have to select anyone of the radio button, then we can click on delete.

but what i want is, i have written a java-script code that gets the radio button value and after that i want to get that javascript variable value to php code and then execute the delete command..

Here is what i have tried

code javascript

<script>
function getResults() {
    var radios = document.getElementsByName("address");    
    for (var i = 0; i < radios.length; i++) {       
        if (radios[i].checked) {
        var a = radios[i].value
            alert(a);
            break;
        }
    }
</script>

php code:

  <?php
      $_GET['a']
      mysql_connect("localhost", "tiger", "tiger") or die (mysql_error ());
      mysql_select_db("theaterdb") or die(mysql_error());
      $strSQL =("DELETE FROM theater WHERE theater_name='"$_POST["a"]"'");
      $rs = mysql_query($strSQL);
      mysql_close();
    ?>
    }

But this is not working

i even tried this also.it is also not working

<?php
    if ($_POST['submit'])
    {
      $_GET['a'];
      mysql_connect("localhost", "tiger", "tiger") or die (mysql_error ());
      mysql_select_db("theaterdb") or die(mysql_error());
      $strSQL =("DELETE FROM theater WHERE address='".$_POST["a"]."'");
      $rs = mysql_query($strSQL);
      mysql_close();
      }
    ?>  
  • 写回答

4条回答 默认 最新

  • dqoys62082 2013-08-21 04:40
    关注

    Hey you need to append php variable as below

     $strSQL =("DELETE FROM theater WHERE theater_name='".$_POST["a"]."'");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器