“动态生成”;提交;PHP中的按钮

“动态生成”;提交;PHP中的按钮,php,forms,submit,Php,Forms,Submit,第一次在这里发帖(所以请温柔一点,因为我是一个相对的PHP新手) 我正在为公司建立一个内部网,我需要做的一件事是创建一个表格,列出所有未完成的销售订单(从我们的会计数据库中提取),并在每个订单旁边提供一个“提交”按钮,以创建相关工单 代码如下: <div class="report_column"> <div class="report_header"> <div class="report_colu

第一次在这里发帖(所以请温柔一点,因为我是一个相对的PHP新手)

我正在为公司建立一个内部网,我需要做的一件事是创建一个表格,列出所有未完成的销售订单(从我们的会计数据库中提取),并在每个订单旁边提供一个“提交”按钮,以创建相关工单

代码如下:

            <div class="report_column">

        <div class="report_header">
            <div class="report_column_title" style="width:150px;margin-left:5px">ship date</div>
            <div class="report_column_title" style="width:200px">customer</div>
            <div class="report_column_title" style="width:140px;text-align:right">item</div>        
            <div class="report_column_title" style="width:120px;text-align:right">quantity</div>
        </div>

    <?php

        // Open connection
        include 'includes/dbconnect.php'; 

        // Perform query
        $result = mysqli_query($con,"SELECT * FROM tSalOrdr ORDER BY dtShipDate ASC");

        // Retrieve results
        while($row = mysqli_fetch_array($result)) {

            $order = $row['lId'];

            if ($row['bCleared'] == 0) {

                $shipdate = substr($row['dtShipDate'], 0,10);
                $customer = $row['sName'];
                $po = $row['sComment'];

                echo '<div class="report_item" style="width:750px";>';

                echo '<form class="form" action="index.php?page=form&item=create_work_order" method="POST">';

                    echo '<div class="report_item_date" style="width:120px">'.$shipdate.'</div>';
                    echo '<div class="report_item_name" style="width:530px">'.$customer;
echo '<input type="hidden" name="po" value="'.$po.'" />';                       
echo '<input type="submit" class="submit" style="height: 25px;width:100px;margin:0px;padding:0px;margin:0px" value="work order"/>';
                    echo '</div>';

                    $result2 = mysqli_query($con,"SELECT * FROM tSOLine WHERE lSOId=$order ORDER BY sDesc ASC");
                    while($row = mysqli_fetch_array($result2)) {

                        if ($row['dRemaining'] <> 0) {

                            echo '<div class="report_item_details">';
                                echo '<div class="report_item_item">'.$row['sDesc'].'</div>';
                                echo '<div class="report_item_quantity">'.$row['dRemaining'].'</div>';
                            echo '</div>';
                        }
                    }

                echo '</form>'; 

                echo '</div>';              

            }
        }

        // Close connection
        mysqli_close($con);

    ?>

    </div>

装船日期
顾客
项目
量

我已经用它制作了17种其他形式,所以我认为这不是问题所在。我希望这只是我的输入错误或逻辑错误。

你可以使用

<button type='submit' class='' name='' onclick=''>Submit</button>
提交

据我所知,您正在将表单转到index.php:

echo '<form class="form" action="index.php?page=form&item=create_work_order" method="POST">';
echo';

你能解释一下当按下按钮时你的预期行为吗?

试着点击一下。请参见下面的示例

input type="button" name="submit" onclick='location.href="index.php?id=$id"'

您好@xaosnaos您的index.php有什么内容请提供如果可能的话index.php页面中有重定向逻辑吗?我尝试了这个,它提供了我需要从POST获取的数据。但是,第一个提交按钮仍然将我带到index.php。好吧,我想已经到一半了:-)谢谢。这个页面的工作方式是这样的。已加载Index.php。“page=form”将特定子页面加载到内容区域。“item=create\u work\u order”将内容加载到内容的“form”部分。就像我上面提到的,我已经做了很多次了,现在,感谢Rohan的建议,除了第一个按钮外,它工作正常,忽略了变量,只是自己加载index.php。
input type="button" name="submit" onclick='location.href="index.php?id=$id"'