这个是要通过两个按钮来重新查询数据库然后更新列表,请问该怎么做。
<?phpif(!isset($_POST['submit']))
{
    exit('非法访问');
}$username = $_POST['username'];
$password = $_POST['password'];$host = '**';
$user = '**';
$pwd  = '**';$conn = mysql_connect($host, $user, $pwd);
if(!$conn)
{
die('数据库连接失败:'.mysql_error());
die('请检查网络配置或联系管理员。');
exit;
}
mysql_select_db("DB_Monitor");$sql = "SELECT * FROM T_User WHERE UserName = '$username' and password = '$password' limit 1";
mysql_query("SET NAMES UTF8");$result = mysql_query($sql) OR die("<br/>ERROR:<b>".mysql_error()."</b><br/><br/><br/>产生问题的sQL<br/>".$sql);
//运营商
$mobile = "";
//当前时间
$datatime = date('Y-m-d H:i:s',time());
if ($num = mysql_num_rows($result))
{
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$mobile = $row['CompanyForShort'];
echo '登陆成功!<br/>';
echo '点击此处<a href="logout.php?action=logout">注销</a>登陆!<br/>';
}
else
{
 exit('登录失败!点击此处 <a href="javascript:history.back(-1);">返回</a> 重试');
}
?><html>
<head><title>国标实时监控数据在线查询</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><center>
<body>
<h1 align = "center">国标实时监控数据在线查询</h1>
<h2 align = "center">
<?php 
$weekday=array('天','一','二','三','四','五','六');
$showtime = date("Y年n月d日 星期").$weekday[date("w")].date(' H:i:s');
 echo "运营商:$mobile    当前时间:$showtime";
 ?>
</h2>  <label>设备名称
  <select name="select">
  <option>所有设备</option>
  <?php
  $sql = "SELECT * FROM T_Device WHERE UserName = '$username'";
  mysql_query("SET NAMES UTF8");
  $result = mysql_query($sql) OR die("<br/>ERROR:<b>".mysql_error()."</b><br/><br/><br/>产生问题的sQL<br/>".$sql);
  if ($sum = mysql_num_rows($result))
  {
   while($row = mysql_fetch_array($result,MYSQL_ASSOC))
    {
  ?>
  <option><?php echo $row['DeviceID'].' - '.$row['Location']; ?></option>
  <?php  
}
  }
  ?>
  </select>
  </label>
<input type ="submit"  name="viewData" value = "查看数据"><input type="submit" name = "viewLog" value="查看错误日志">
<table width = "75%" border = "0" cellpadding = "0" cellspacing = "1" bgcolor = "#7B7B84">
    <tr bgcolor = "#8BBCC7">
        <td height = "33"><div align = "center"><strong>设备ID</strong></div></td>
        <!-- <td><div align = "center"><strong>位置</strong></div></td> -->
        <td><div align = "center"><strong>数据发送时间</strong></div></td>
        <td><div align = "center"><strong>GPS经度</strong></div></td>
        <td><div align = "center"><strong>GPS纬度</strong></div></td>
        <td><div align = "center"><strong>锁定状态</strong></div></td>
        <td><div align = "center"><strong>频点</strong></div></td>
        <td><div align = "center"><strong>信号电平</strong></div></td>
        <td><div align = "center"><strong>载噪比</strong></div></td>
        <td><div align = "center"><strong>频率偏移</strong></div></td>
        <td><div align = "center"><strong>调制方式</strong></div></td>
        <td><div align = "center"><strong>LDPC</strong></div></td>
        <td><div align = "center"><strong>PN</strong></div></td>
        <td><div align = "center"><strong>载波</strong></div></td>
        <td><div align = "center"><strong>误码率</strong></div></td>
    </tr>    <?php 
$sql = "SELECT * FROM T_Data WHERE(DeviceID IN (SELECT DeviceID FROM T_Device WHERE UserName='$username'))";
$result = mysql_query($sql) OR die("<br/>ERROR:<b>".mysql_error()."</b><br/><br/><br/>产生问题的sQL<br/>".$sql);
    if ($sum = mysql_num_rows($result))
    {
     while($row = mysql_fetch_array($result,MYSQL_ASSOC))
     {
     $LockStatus = ord($row["LockStatus"]);
            $SCMC = ord($row["SCMC"]);
$QAM = $row["Qam"];
//If LoskStatus = 0,SCMC and QAM don't display,
     if($LockStatus == 0)
     {
     $LockStatus = "未锁定";
$QAM = "";
$SCMC = "";
     }
     else 
     {
     $LockStatus = "锁定";

if ($QAM == 0)
     {
     $QAM = "4QAM-NR";
     }
     else
     {
     $QAM = $QAM."QAM";
     }

if ($SCMC == 0)
          {
     $SCMC = "单载波";
     }
     else
     {
     $SCMC = "多载波";
     }
     }        
    ?>
    <tr bgcolor = "#FFFFFF">
        <td height = "22" align = "center"><?php echo $row['DeviceID'];?>&nbsp;</td>
        <!-- <td height = "22" aligh = "center"><?php echo $row['Location'];?>&nbsp;</td> -->
        <td height = "22" align = "center"><?php echo $row['Time'];?>&nbsp;</td>
        <td height = "22" align = "center"><?php echo $row['Longitude'];?>&nbsp;</td>
        <td height = "22" align = "center"><?php echo $row['Latitude'];?>&nbsp;</td>
        <!-- <td height = "22" aligh = "center"><?php echo $row['LockStatus'];?>&nbsp;</td> -->
        <td height = "22" align = "center"><?php echo $LockStatus;?>&nbsp;</td>
        <td height = "22" align = "center"><?php echo $row['FrequencyPoint'];?>&nbsp;</td>
        <td height = "22" align = "center"><?php echo $row['RSSI'];?>&nbsp;</td>
        <td height = "22" align = "center"><?php echo $row['CN'];?>&nbsp;</td>
        <td height = "22" align = "center"><?php echo $row['FrequencyOffset'];?>&nbsp;</td>
        <td height = "22" align = "center"><?php echo $QAM;?>&nbsp;</td>
        <td height = "22" align = "center"><?php echo $row['Fec'];?>&nbsp;</td>
        <td height = "22" align = "center"><?php echo $row['PN'];?>&nbsp;</td>
        <td height = "22" align = "center"><?php echo $SCMC;?>&nbsp;</td>
        <td height = "22" align = "center"><?php echo $row['BLER'];?>&nbsp;</td>
    </tr>
    <?php 
     }
    }
    mysql_close($conn)
    ?></table>
</body>
</center>
</html>

解决方案 »

  1.   

    通过点击事件,触发ajax请求。
      

  2.   


    我上个星期才临时接了个PHP的任务,post不是传递表单吗,我只想在这个页面上进行查询,不要跳到别的页面,这个要怎么传递啊。。
      

  3.   


    能不能麻烦说的再具体一些,我上个礼拜接的任务,之前从来没接触过php和html的东西感激不尽啊。
      

  4.   


    <script src=jquery.js></script>
    <input type=submit id=submit name="viewData" value = "查看数据">
    //$(#submit) 获取查看数据这个按钮
    //$($submit).post() ajax提交方式
    //look.php 提交到的php文件 $json 传输的数据格式比如{id:1} data 返回值
    $(#submit).post(look.php,{$json},function(data)
    {
      alert(data)
    });
    return false; //取消默认提交
     具体的就是查看jquery如何ajax提交的方式。
      

  5.   


    能不能麻烦说的再具体一些,我上个礼拜接的任务,之前从来没接触过php和html的东西感激不尽啊。就这样也敢接任务……我佩服你……
      

  6.   


    能不能麻烦说的再具体一些,我上个礼拜接的任务,之前从来没接触过php和html的东西感激不尽啊。就这样也敢接任务……我佩服你……没办法这都是领导一句话的事儿。