从表中的一行将数组数据发布到另一个表php / html中

时间:2015-02-19 21:19:18

标签: php html mysql submit html-table

好的,我正在尝试完成一个编辑页面,我找不到以前发布的任何地方。我正在使用一个数组从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>";
            ?>

1 个答案:

答案 0 :(得分:0)

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