试图从通过为每个显示的表中回显一列

我正在使用这张表并试图在警报中呼应“branchid” 

http://img1.mukewang.com/618e2596000100ce14300315.jpg

有两个表:


订单地址.php


<?php

  session_start();

  require_once('orders_address.vc.php');

?>

这是我对每张桌子的片段,“branchid”和分配按钮只是这里的问题


                    <td>

                      <a href="order_address.vc.php<?php echo '?branchid='.$rowAddress['branchid']; ?>">

                        <input type="submit" class="btn button-color-blue font-color-white full_width" name="assign" value="ASSIGN">

                      </a>

                    </td>


                    <td class="table-text-center">

                      <?php

                          echo($rowAddress['branchid']);

                      ?>

                    </td>

订单地址.vc.php


下面是点击按钮时的代码


  if (isset($_POST['assign']) && $_POST['assign'] == 'ASSIGN')

  {

    $branchid = $_GET ['branchid'];

    echo "<script type='text/javascript'>alert('$branchid');</script>";

    }

目前我得到一个未定义的索引并且警告框是空的。$_GET ['branchid'] 似乎没有检索到我想要的列。


感谢您的任何帮助。


鸿蒙传说
浏览 217回答 4
4回答

BIG阳

<td>&nbsp; &nbsp; <?php&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; $branchid = isset($rowAddress['branchid']) ? $rowAddress['branchid'] : 0;&nbsp;&nbsp; &nbsp; ?>&nbsp; &nbsp; <form method="POST" action="order_address.vc.php">&nbsp; &nbsp; &nbsp; &nbsp; <input type="hidden" name="branchid" value="<?php echo $branchid ?>" />&nbsp; &nbsp; &nbsp; &nbsp; <input type="hidden" name="assign" value="ASSIGN" />&nbsp; &nbsp; &nbsp; &nbsp; <input type="submit" value="ASSIGN" class="btn button-color-blue font-color-white full_width" />&nbsp; &nbsp; </form></td><td class="table-text-center">&nbsp; <?php echo $branchid; ?></td>orders_address.vc.php:if(isset($_POST['assign']) && $_POST['assign'] === 'ASSIGN') {&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; echo '<script type="text/javascript">';&nbsp; &nbsp; echo 'alert('.$_POST['branchid'].')';&nbsp; &nbsp; echo '</script>';}

眼眸繁星

我不知道为什么你有一个围绕锚标记的表单提交按钮。当提交标签被点击时,老实说,我不知道哪个优先,锚标签或表单提交。假设您将表格包装在 HTML 表单中并发出 POST 请求。我建议添加branchid作为提交按钮的值。前任:&nbsp;<input type="submit" class="..." name="assign" value="<?=$rowAddress['branchid']?>">在接收端,您可以branchid从$_POST['assign']if (! empty($_POST['assign'])){&nbsp; &nbsp; $branchid = $_POST['assign'];&nbsp; &nbsp; echo "<script type='text/javascript'>alert('$branchid');</script>";}

幕布斯6054654

因为你$_GET['branchid']在POST处理if&nbsp;(isset($_POST['assign'])&nbsp;&&&nbsp;$_POST['assign']&nbsp;==&nbsp;'ASSIGN')&nbsp;...但是您像往常一样发送GEThref 链接,因此条件POST永远不会为真。

拉丁的传说

if (isset($_POST['assign']) && $_POST['assign'] == 'ASSIGN'){$branchid = $_GET ['branchid'];echo "<script type='text/javascript'>alert('$branchid');</script>";}HTML 应如下所示:<form action="order_address.vc.php" method="POST">&nbsp; &nbsp; &nbsp; &nbsp; <input type="hidden" name="branchid" value="<?php echo $branchid ?>" />&nbsp; &nbsp; &nbsp; &nbsp; <input type="submit" name="assign" value="ASSIGN" /></form>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript