簡體   English   中英

如何在同一頁面中顯示輸入和輸出?

[英]how to display input and output in same page?

我只有一個PHP文件。 但使用兩個單獨的PHP標簽。 如果單擊第一個PHP標記表中的第一行,則需要在同一頁面的第二個PHP標記表中顯示第一行的值。 兩個表的公共字段是order_id輸出應顯示在第一個表的旁邊。

<head>               
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>

<script type="text/javascript">
$(function() {
$('.one').click(function() {
$(".slidediv").slideToggle();
});

});
</script>
</head>
<body>
<?php
            session_start();
            include "db.php";
            $query = "select * from orders_list";
            $result = mysql_query($query);

            $num_rows = mysql_num_rows($result);
            if($num_rows >= 1)
                {
                echo "<div id='showmenu' class='scroll'>";  
            echo "<table id='table_struct' cellspacing='0' cellpadding='1' border='1' width='400'>
                 <tr class='tr_class' bgcolor='#0066CC'>
                 <td align='center' style='font-weight:bold'> Select </td>
                 <td align='center' style='font-weight:bold'> order_id </td>
                 <td align='center' style='font-weight:bold'> customer_name </td>
                 <td align='center' style='font-weight:bold'> no_of_pack </td>
                 <td align='center' style='font-weight:bold'> price </td>
                 <td align='center' style='font-weight:bold'> Weight </td>
                 <td align='center' style='font-weight:bold'> payment mode </td>



            </tr>";

                while($row = mysql_fetch_array($result))

                {


                        echo "<tr class='one' data-id='".$row['order_id']."'>
                        <td align='center'><input type='checkbox' class='case' name='case' value='1'></td>
                        <td align='center'>".$row['order_id']."</td>
                        <td align='center'>".$row['customer_name']."</td>
                        <td align='center'>".$row['number_of_pack']."</td>
                        <td align='center'>".$row['price']."</td>
                        <td align='center'>".$row['weight']."</td>
                        <td align='center'>".$row['payment']."</td>";


                        /*echo "<td align='center'><a href='pin.php?increment_id=".$row['increment_id']."&postcode=".$row['postcode']."&proposed_shipping=".$proposed_shipping." '>SUBMIT</a></td>";*/

                echo "</tr>";
                        }
                        $order_id = $row['order_id'];
                        global $order_id;
                        echo "</table>";
                        echo "</div>";
                        }


        if(!mysql_close($con))
        {
            echo "failed to close";
        }   

            ?>

            <div>
            <?php

            include "db.php";

            global $order_id;
            $query = "select * from orders_details where order_id=$order_id";
            echo $query;
            $result = mysql_query($query);

            $num_rows = mysql_num_rows($result);
            if($num_rows >= 1)
                {
                echo "<div class='menu' class='scroll'>";   
            echo "<table id='table_struct' cellspacing='0' cellpadding='1' border='1' width='400'>
                 <tr class='slidediv' bgcolor='#0066CC'>
                 <td align='center' style='font-weight:bold'> Product </td>
                 <td align='center' style='font-weight:bold'> Quantity </td>
                 <td align='center' style='font-weight:bold'> Sku </td>
                 <td align='center' style='font-weight:bold'> Price </td>
                 <td align='center' style='font-weight:bold'> Total </td>

            </tr>";

                while($row = mysql_fetch_array($result))
                {
                        echo "<tr class='slidediv'>
                        <td align='center'><input type='checkbox' class='case' name='case' value='1'></td>
                        <td align='center'>".$row['product']."</td>
                        <td align='center'>".$row['quantity']."</td>
                        <td align='center'>".$row['sku']."</td>
                        <td align='center'>".$row['price']."</td>
                        <td align='center'>".$row['total']."</td>";

                echo "</tr>";
                        }
                        echo "</table>";
                        echo "</div>";
                        }
        if(!mysql_close($con))
        {
            echo "failed to close";
        }   
            ?>
</body>

無需全局聲明$ order_id,只需將您的代碼$ order_id = $ row ['order_id']; 在while循環內,並在您的頁面中的任何地方使用它並享受。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM