dskyx46424 2013-10-29 08:41
浏览 37
已采纳

如何在会话中存储整个$ _POST变量

I have dropdown select that when I click the submit button it's displays the records base on the value of dropdown. It's works fine, but when I refresh the app_list2.php it's displays nothing. I want to stay the records that displays in app_list2.php. How I can store all the $_POST value in session ?

    <?php
    $mysqli = new mysqli("localhost", "root", "", "app");
    if(isset($_POST['submit'])){
    $drop = $_POST['drop_1'];
    $tier_two = $_POST['tier_two'];

    $where = "WHERE app_cn='$drop' AND app_plan_no='$tier_two'";

$result1 = $mysqli->query("
    SELECT *, SUM(unit_cost*quantity) AS total_amount, SUM(unit_cost*1st_quarter) AS 1st_quarter_total, SUM(unit_cost*2nd_quarter) AS 2nd_quarter_total, SUM(unit_cost*3rd_quarter) AS 3rd_quarter_total,
    SUM(unit_cost*4th_quarter) AS 4th_quarter_total, SUM((quantity)-(1st_q_qty_del+2nd_q_qty_del+3rd_q_qty_del+4th_q_qty_del)) AS balance
    FROM app 
    $where 
    GROUP BY counter ORDER BY counter
");
?>

<?php
echo'<table id="tfhover" cellspacing="0" class="tablesorter" style="text-transform:uppercase;">
        <thead>
            <tr>
        <th>Item</th>
        <th>Description</th>
        <th>Fund Source</th>
        <th>Unit</th>
        <th>Unit Cost</th>
    </tr>
        </thead>';
        echo'<tbody>';
$i=1;
while($row = $result1->fetch_assoc()){
if($row['app_cn'] != '')
 {
 echo'<tr>
    <td>'.$row['item_name'].'</td>
        <td>'.$row['item_description'].'</td>
    <td>'.$row['fund_source'].'</td>
        <td>'.$row['unit'].'</td>
        <td>'.number_format($row['unit_cost'], 2, '.', ',').'</td>
       </tr>';
    }
        }
    echo "</tbody></table>";
}
?>
  • 写回答

1条回答 默认 最新

  • douneiben2240 2013-10-29 09:20
    关注

    try out this code

    <?php
    
        ob_start();
        session_start();
            $mysqli = new mysqli("localhost", "root", "", "app");
    
    
    
        if(isset($_POST['submit'])){
    
        //unset the session value 
        $_SESSION['content'] = '';
    
        $drop = $_POST['drop_1'];
        $tier_two = $_POST['tier_two'];
    
        $where = "WHERE app_cn='$drop' AND app_plan_no='$tier_two'";
    
    $result1 = $mysqli->query("
        SELECT *, SUM(unit_cost*quantity) AS total_amount, SUM(unit_cost*1st_quarter) AS 1st_quarter_total, SUM(unit_cost*2nd_quarter) AS 2nd_quarter_total, SUM(unit_cost*3rd_quarter) AS 3rd_quarter_total,
        SUM(unit_cost*4th_quarter) AS 4th_quarter_total, SUM((quantity)-(1st_q_qty_del+2nd_q_qty_del+3rd_q_qty_del+4th_q_qty_del)) AS balance
        FROM app 
        $where 
        GROUP BY counter ORDER BY counter
    ");
    ?>
    
    <?php
    echo'<table id="tfhover" cellspacing="0" class="tablesorter" style="text-transform:uppercase;">
            <thead>
                <tr>
            <th>Item</th>
            <th>Description</th>
            <th>Fund Source</th>
            <th>Unit</th>
            <th>Unit Cost</th>
        </tr>
            </thead>';
            echo'<tbody>';
    $i=1;
    while($row = $result1->fetch_assoc()){
    if($row['app_cn'] != '')
     {
     echo'<tr>
        <td>'.$row['item_name'].'</td>
            <td>'.$row['item_description'].'</td>
        <td>'.$row['fund_source'].'</td>
            <td>'.$row['unit'].'</td>
            <td>'.number_format($row['unit_cost'], 2, '.', ',').'</td>
           </tr>';
        }
            }
        echo "</tbody></table>";
    
        $sPageContent = ob_get_clean();
        $_SESSION['content']    =   $sPageContent;
    
    }else{
    
        if (isset($_SESSION['content'])){
            echo $_SESSION['content'];
        }
    
    
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛