dongnunai3125 2015-08-20 08:45
浏览 38

更改表单提交中的变量值

I am trying to have a div show itself when the form is submitted. I have the following code and I cannot figure out how to go about this.

<?php
    session_start();
    $locale_db_host  = 'localhost';
    $locale_db_name  = 'xxxx';
    $locale_db_login = 'xxxx';
    $locale_db_pass  = 'XXXX';


    // connect to db
    $linkmb = mysql_connect($locale_db_host, $locale_db_login, $locale_db_pass)
           or die("Could not connect : " . mysql_error());
    //echo "Connected successfully
";
    mysql_select_db($locale_db_name, $linkmb) or die("Could not select database $locale_db_name");


    if(isset($_POST['submit'])) 
    {

    $sdate=$_POST['time3'];
    $edate=$_POST['time5'];
    $query=$_POST['query'];
    $output=$_POST['output'];

    $_SESSION['time3']="$sdate";
    $_SESSION['time5']="$edate";

    $t=time();
    $filename="/var/www/html/dialer/output/$t.csv";

    }
    ?>
    <div id="dialer">
      <form name="dialer" id="dialer" action="" method="post" enctype="multipart/form-data" onsubmit="showHide(); return false;">
      <input type="hidden" name="mode" id="mode" value="insert" />
    <table align="left" class="tbl_altcolor shadow" style="width:35%; margin-left:20px">
        <tbody>
        <tr>
             <td>Date-From:</td>
              <td>
                 <input type="Text" id="demo3" class="input required"  size="10" name="time3" required>
                 <img src="images2/date.png" align="center" width="20" height="20" border="0" onclick="javascript:NewCssCal('demo3','yyyyMMdd')" style="cursor:pointer"/>
                  <span class="descriptions"></span>
                </td>

                   <td>Date-To:</td>
              <td>
                 <input type="Text" id="demo2" class="input required"  size="10" name="time5" required>
                 <img src="images2/date.png" align="center" width="20" height="20" border="0" onclick="javascript:NewCssCal('demo2','yyyyMMdd')" style="cursor:pointer"/>
                <span class="descriptions"></span>
                </td>             
        </tr>

         <tr><td><span class="clear" style="float:left; margin-top:5px;margin-bottom:5px; margin-left:10px;"><input type="submit" name="submit" required class="btn"  value="submit" ></span></td></tr>
           </tbody>
          </table>       
        </form>
    </div>  

    <script type="text/javascript" src="datetimepicker_css.js" /></script>

    <script type="text/javascript">
     function showHide() {
       var div = document.getElementById("formhide");
       if (div.style.display == 'none') {
         div.style.display = '';
       }
       else {
         div.style.display = 'none';
       }
     }
    </script>
    <?php
    $tempdata = "";
    $html = "<html>
             <head>
             <style>
                table{margin:10px auto;}
                table.tblheadgreen {
                        font-size:14px;
                        color:#333333;
                        border-width: 1px;
                        border-color: #a9c6c9;
                        border-collapse: collapse;
                }
                table.tblheadgreen th {
                        border-width: 1px;
                        padding: 8px 7px;
                        border-style: solid;
                        border-color: #999999;
                        font-weight:bold;
                        background-color:rgb(15, 167, 181);
                        color:#FFF;
                }
                table.tblheadgreen td {
                        border-width: 1px;
                        padding: 5px 7px;
                        border-style: solid;
                        border-color: powderblue;
                }
                table.tblheadgreen tbody tr:nth-child(odd){
                        background-color:rgb(190, 245, 250);
                }
                table.tblheadgreen tbody tr:nth-child(even){
                        background-color:rgb(237, 253, 254);
                }
                </style>
             </head>
             <body>
             <p>Hello </p>
             <p></p>
            <table border='1' cellpadding='0' cellspacing='0' class='tblheadgreen' width='800px'>
            <tr>
              <th align='left'>CallTime</th>
              <th align='left'>Callee</th>
              <th align='left'>Called</th>
              <th align='left'>Duration</th>
              <th align='left'>Call Type</th>
            </tr>
            <tbody>";
    ?>
    <div id="formhide"  name="formhide" style="display:none">
    <html>
    <head>
    <style>
    table{margin:10px auto;}
    table.tblheadgreen {
            font-size:14px;
            color:#333333;
            border-width: 1px;
            border-color: #a9c6c9;
            border-collapse: collapse;
    }
    table.tblheadgreen th {
            border-width: 1px;
            padding: 8px 7px;
            border-style: solid;
            border-color: #999999;
            font-weight:bold;
            background-color:rgb(15, 167, 181);
            color:#FFF;
    }
    table.tblheadgreen td {
            border-width: 1px;
            padding: 5px 7px;
            border-style: solid;
            border-color: powderblue;
    }
    table.tblheadgreen tbody tr:nth-child(odd){
            background-color:rgb(190, 245, 250);
    }
    table.tblheadgreen tbody tr:nth-child(even){
            background-color:rgb(237, 253, 254);
    }
    </style>
    </head>
    <body>
    <table border="1" cellpadding="0" cellspacing="0" class="tblheadgreen" width="800px">
    <tr>
      <th align="left">CallTime</th>
      <th align="left">Caller</th>
      <th align="left">Callee</th>
      <th align="left">Duration</th>
      <th align="left">BillSecond </th>
    </tr>

    <?php
    $sdate=$_SESSION['time3'];
    $edate=$_SESSION['time5'];


    $sql="SELECT `calldate`,`src`,`dst`,`billsec`,`duration` FROM cdr WHERE calldate >= '$sdate' AND calldate <= '$edate'";
    error_log("-----$sql--**-$sdate---");

    if(!($result = mysql_query($sql, $linkmb))) {
        print("Invalid query: " . mysql_error()."
");
        print("SQL: $sql
");
        die();
    }
    // $row_cnt = $result->num_rows;
    while($row = mysql_fetch_array($result))
    {
        //file_put_contents($tmpfile,$row['clid'].",".$row['src'].",".$row['dst'].",".$row['dcontext']."
");
        //file_get_contents($tmpfile);
        $tempdata .= $row['calldate'].",".$row['src'].",".$row['dst'].","
                     .$row['duration'].",".$row['billsec']."
";

        $html .= "<tr>
                  <td>".$row['calldate']."</td>
                  <td>".htmlentities($row['src'])."</td>
                  <td>".$row['dst']."</td>
                  <td>".$row['duration']."</td>
                  <td>".$row['billsec']."</td>
                </tr>"; 
    ?>
    <tr>
      <td><?php echo $row['calldate'];?></td>
      <td><?php echo htmlentities($row['src']);?></td>
      <td><?php echo $row['dst'];?></td>
      <td><?php echo $row['duration'];?></td>
      <td><?php echo $row['billsec'];?></td>
    </tr>
    <?php 
    }
    ?>
    </tbody>
    </table>
    </html>
    <div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度