我正在尝试在提交表单时自己进行div显示。我有以下代码,我无法弄清楚如何解决这个问题。
<?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\n";
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()."\n");
print("SQL: $sql\n");
die();
}
// $row_cnt = $result->num_rows;
while($row = mysql_fetch_array($result))
{
//file_put_contents($tmpfile,$row['clid'].",".$row['src'].",".$row['dst'].",".$row['dcontext']."\n");
//file_get_contents($tmpfile);
$tempdata .= $row['calldate'].",".$row['src'].",".$row['dst'].","
.$row['duration'].",".$row['billsec']."\n";
$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>