dongtao9095 2014-09-04 23:16
浏览 52
已采纳

如何在while循环中更改php中的表单名称?

    $friendRequests = ("SELECT * FROM zahtjevi_prijatelja WHERE user_to='".$_SESSION['ID']."'");
    $res = mysql_query($friendRequests) or die(mysql_error());
    if (mysql_num_rows($res) ==0) {
     echo "You have no friend Requests at this time.";
     $user_from = "";
    }
    else
    {


     while ($get_row = mysql_fetch_assoc($res)) {

While return all friend requests ,and create form for every request. Form is in while-loop. What i want to do is that if I press submit button for one of requests that i get, add only for pressed to database, but in my case all requests are added. Its because form name is always the same in while-loop so i need some how dynamically change name of form if there is more friend requests.

      <form action="friendRequest.php" method="post" id="myForm"
    enctype="multipart/form-data">



    <input type="submit" name="acceptrequest" value="Accept Request">
    <input type="submit" name="ignorerequest" value="Ignore Request"><br>


    </form>
<?php
    }
?>
  • 写回答

2条回答 默认 最新

  • douzhuan1169 2014-09-04 23:26
    关注

    Maybe a multiselect dropdown to accept multiple requests or a single one at a time?

    <form>
    <label for="accept_request"
    <select multiple name="accept_request[]">
      <option value="1">Friend Request 1</option>
      <option value="2">Friend Request 2</option>
      <option value="3">Friend Request 3</option>
      <option value="4">Friend Request 4</option>
    </select>
    
    </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 wpf中在模版中寻找元素
  • ¥15 MFC平台生成指定圆
  • ¥15 jmeter出现403
  • ¥500 求华为P30PRO手机硬盘数据恢复
  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关
  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥15 怎样删除 右键菜单里的 剪切(T)和复制(C)
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题