post 数组数据从 table 中的一行到另一个 table php/html

post array data from a row in table into another table php/html

好的,所以我正在尝试完成一个编辑页面,但我找不到以前发布过的任何地方。我正在使用一个数组从 sql 中提取数据,并且一切正常。我想专门从一行中提取数据,以根据所选按钮在一页上编辑或删除另一页。如果我可以获得有关如何完成此操作的帮助,请告诉我。我正在使用 php.

首页

<?php
            include "cxn.php";
            $cxn = mysqli_connect($host, $user, $passwd, $dbname) or die ("CXN FAILED");
            $query = "SELECT * FROM Users ORDER BY userName";
            $result = mysqli_query($cxn,$query) or die ("query failed");
            $counter=0;
            echo "<table width=500px text-align=left>";
            echo "<tr><th style='background-color='black;'></th><th>User Name</th><th>Password</th></tr>\n";
            while ($row=mysqli_fetch_array($result)) {
                $fuserName = $row["userName"];
                $fpassword = $row["password"];
                echo "<tr><td style='width='50px';background-color='black';'>
                     <form method='post' action='edit.php' input='".$row."'>
                     <input type='submit' method='post' value='Edit'></form>
                     <form method='post' action='delete.php' input='".$row."'>
                     <input type='submit' method='post' value='Delete'></form>
                     </td><td style='width=200px;'>".$fuserName."</td><td style='width=200px;'>".$fpassword."</td></tr>\n";
                $counter++;
            }
            echo "</table>";
            ?>

第二页

<?php
            include "cxn.php";
            $cxn = mysqli_connect($host, $user, $passwd, $dbname) or die ("CXN FAILED");
            $query = "SELECT * FROM Users ORDER BY userName";
            $result = mysqli_query($cxn,$query) or die ("query failed");

            echo "<table width='500px' text-align='left'";
            echo "<tr><th style='background-color='black;'></th><th>User Name</th><th>Password</th></tr><tr><td>\n";
            foreach ($_POST as $field => $value) 
            {
                echo "".$field." = ".$value." <br />\n";
            }
            echo "</td></tr></table>";
            ?>

在您的第一页中,input= 不是有效的 <form> 标记属性。 <form method='post' action='edit.php' input='".$row."'>