问个白痴问题。。如何通过按钮刷新列表。。。

wandingwei 2013-10-30 04:19:49
这个是要通过两个按钮来重新查询数据库然后更新列表,请问该怎么做。。。。




<?php

if(!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'];?> </td>
<!-- <td height = "22" aligh = "center"><?php echo $row['Location'];?> </td> -->
<td height = "22" align = "center"><?php echo $row['Time'];?> </td>
<td height = "22" align = "center"><?php echo $row['Longitude'];?> </td>
<td height = "22" align = "center"><?php echo $row['Latitude'];?> </td>
<!-- <td height = "22" aligh = "center"><?php echo $row['LockStatus'];?> </td> -->
<td height = "22" align = "center"><?php echo $LockStatus;?> </td>
<td height = "22" align = "center"><?php echo $row['FrequencyPoint'];?> </td>
<td height = "22" align = "center"><?php echo $row['RSSI'];?> </td>
<td height = "22" align = "center"><?php echo $row['CN'];?> </td>
<td height = "22" align = "center"><?php echo $row['FrequencyOffset'];?> </td>
<td height = "22" align = "center"><?php echo $QAM;?> </td>
<td height = "22" align = "center"><?php echo $row['Fec'];?> </td>
<td height = "22" align = "center"><?php echo $row['PN'];?> </td>
<td height = "22" align = "center"><?php echo $SCMC;?> </td>
<td height = "22" align = "center"><?php echo $row['BLER'];?> </td>
</tr>
<?php
}
}
mysql_close($conn)
?>

</table>
</body>
</center>
</html>


...全文
205 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wandingwei 2013-10-31
  • 打赏
  • 举报
回复
引用 7 楼 TR@SOE 的回复:
[quote=引用 4 楼 wandingwei 的回复:] [quote=引用 2 楼 u011684994 的回复:] 通过点击事件,触发ajax请求。
能不能麻烦说的再具体一些,我上个礼拜接的任务,之前从来没接触过php和html的东西。。。感激不尽啊。[/quote] 就这样也敢接任务……我佩服你……[/quote] 没办法。。。这都是领导一句话的事儿。。。。
wandingwei 2013-10-31
  • 打赏
  • 举报
回复
引用 5 楼 mahuatengBC 的回复:
可以跳转到本页面,根据获取的参数,访问数据库,获得对应的结果集
十分感激。。。。
wandingwei 2013-10-31
  • 打赏
  • 举报
回复
还是不知道怎么传。。。。。-__-
TR@SOE 2013-10-30
  • 打赏
  • 举报
回复
引用 4 楼 wandingwei 的回复:
[quote=引用 2 楼 u011684994 的回复:] 通过点击事件,触发ajax请求。
能不能麻烦说的再具体一些,我上个礼拜接的任务,之前从来没接触过php和html的东西。。。感激不尽啊。[/quote] 就这样也敢接任务……我佩服你……
Hx_Moon_ 2013-10-30
  • 打赏
  • 举报
回复

<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提交的方式。
mahuatengBC 2013-10-30
  • 打赏
  • 举报
回复
可以跳转到本页面,根据获取的参数,访问数据库,获得对应的结果集
wandingwei 2013-10-30
  • 打赏
  • 举报
回复
引用 2 楼 u011684994 的回复:
通过点击事件,触发ajax请求。
能不能麻烦说的再具体一些,我上个礼拜接的任务,之前从来没接触过php和html的东西。。。感激不尽啊。
wandingwei 2013-10-30
  • 打赏
  • 举报
回复
引用 1 楼 linux_PHP_ 的回复:
$.post()
我上个星期才临时接了个PHP的任务,post不是传递表单吗,我只想在这个页面上进行查询,不要跳到别的页面,这个要怎么传递啊。。
_HUA_ 2013-10-30
  • 打赏
  • 举报
回复
通过点击事件,触发ajax请求。
Hx_Moon_ 2013-10-30
  • 打赏
  • 举报
回复
$.post()

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧