duanke3985 2019-05-16 15:26
浏览 329
已采纳

如何在单击行特定按钮时将从数据库获取的记录值传递到另一个PHP页面

I m trying to pass the email fetched from database to next page based on the row button clicked. But i m not able to use inside the value attribute of tag.

i have created a button for each row. for any button clicked i want to move to a common page with row email. the email varies based on selected button.

while($row= mysqli_fetch_assoc($results))
{
   $_email=$row["email"];
   echo  "<tr><td>". $row["email"] ."</td><td>" . $row["name"] .
   "</td><td>". $row["credit"] ."</td><td>".
   '<form method="post" action="user.php">
    <input type="hidden" name="data" value="<?php echo $_email?>"/>
    <button><b>Home<b></button>
    </form>'. "</td></tr>";
}

the email corresponding to the row button should be avialable in user.php file using $_POST method. i m not getting email value when i m doing $data=$_POST["data"] in the user.php page

  • 写回答

1条回答 默认 最新

  • douwan4993 2019-05-16 15:35
    关注

    If you use a double quote outer wrapper and then single quotes inside that wrapper for the attributes, it easier to read and debug.

    Also remember that if you have an assoc array and you want to place $row["email"] inside the double quoted string literal, you can leave the " off like this $row[email]

    See your edited code below

       $_email=$row["email"];
       echo 
        "<tr>
            <td>$row[email]</td>
            <td>$row[name]</td>
           <td>$row[credit]</td>
           <td>
                <form method='post' action='user.php'>
                    <input type='Hidden' name='data' value='$_email'/>
                    <button><b>Home<b></button>
                </form>
            </td>
        </tr>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?