【问题标题】:post array data from a row in table into another table php/html [closed]将数组数据从表中的一行发布到另一个表 php/html [关闭]
【发布时间】:2015-02-20 05:28:25
【问题描述】:

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

【问题讨论】:

    标签: php html mysql submit html-table


    【解决方案1】:

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

    【讨论】:

    • 我标记为完成。那是问题之一。其余的我可以自己配置并简化我想要完成的工作。谢谢!
    猜你喜欢
    • 2016-04-13
    • 2015-11-19
    • 1970-01-01
    • 2016-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    相关资源
    最近更新 更多