doutuzhuohao6449 2016-11-15 15:19
浏览 12
已采纳

在我的值中发送带有帖子的两个键=“”

I wonder how i could send two primary keys with my POST? So far i can only figure out how i can send one. This is how i get one with my button value='$id' And now i need my $key also so i can update my sql. Do i need to do it in a array? or make a string with them two together?

My db

    while((db2_fetch_row($queryexe)) and ($counter < $max)) {
     $key = db2_result($queryexe, 'PKEY');
     $id = db2_result($queryexe, 'PID');
     $akt = db2_result($queryexe, 'AKT');

Tables + my button

print("<td>$key</td>
");
print("<td class='center'>$id</td>
");
print("<td><form class='form-horizontal' method='post'><button  name = 'test' 
type='submit' id = 'test' value='$id' class='btn btn-default'>
<i class='glyphicon glyphicon-repeat'></i> Klar
  </button></form></td>
");

And my button

       if(isset($_POST['test'])) {
                $dbhost = '***';
                $dbuser = '***';
                $dbpass = '***';

                $conn = db2_connect($dbhost, $dbuser, $dbpass);

                if(! $conn ) {
                   die('Could not connect: ');
                }


                $sql = "UPDATE MYDB SET AKT = 'X' 
                WHERE PKEY = '$key' AND PID = $id ";
                $retval =  db2_exec( $conn, $sql);

                if(! $retval ) {
                  die('Could not update data: ' . db2_stmt_errormsg());
                }
                echo "Updated data successfully
";
                db2_close($conn); 
             }   


}
  • 写回答

1条回答 默认 最新

  • douduonang3169 2016-11-15 15:34
    关注

    Theres an input type called hidden it's basically a way to pass a variable but never actually show it. like this:

    <input type="hidden" name="key" value="$key" > 
    

    After submitting, $_POST['key'] = the value of this hidden field.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?