如题 想做个简单的查询系统:
现在搞了个没有表单的,代码如下:
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("cbd", $con);$result = mysql_query("SELECT date,ip, count(ip) as count FROM syn_number WHERE date like '%05-08%' group by ip order by count desc limit 10");echo "<table border='1'><tr>
<th>date</th>
<th>ip</th>
<th>number</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>现在想把这段代码sql语句中的 05-08 和最后的limit 10 数字10 改为用表单提交,每次我可以输入
0508最好是可以输入一个范围 比如0508到0510 这样请问该如何实现?用表单的话 是要再搞个html文件了?
现在搞了个没有表单的,代码如下:
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("cbd", $con);$result = mysql_query("SELECT date,ip, count(ip) as count FROM syn_number WHERE date like '%05-08%' group by ip order by count desc limit 10");echo "<table border='1'><tr>
<th>date</th>
<th>ip</th>
<th>number</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>现在想把这段代码sql语句中的 05-08 和最后的limit 10 数字10 改为用表单提交,每次我可以输入
0508最好是可以输入一个范围 比如0508到0510 这样请问该如何实现?用表单的话 是要再搞个html文件了?
解决方案 »
- php账号输入进入页面之后保持登陆状态的怎么实现啊?很急!
- 求助 关于用php写入文件的问题
- 请教转义字符 \ 的问题。
- 怎么把时间最新的显示出来?
- 急...读取时只想读取文字不想读取出图片
- 初次写PHP的问题!
- ADODB+StmartTemplate+PHP做的仿DISCUZ论坛,呵呵,大家看看怎么样?
- 在smarttemplate的使用过程中,看看我这样写哪里错了?运行的结果不太正确。..............................
- 鸟来的邮件
- 快崩溃了,昨天一下午都没解决。
- 出现phpMyAdmin - 错误,无法加载 mysqli (外链,英语) 扩展,请检查您的 PHP 配置 - 文档的几个成功解决方法
- 如何用javascript获取控件的值
-----------htmlLimit:
<input type="text" name="start" />
<input type="text" name="end" />
再加一行
echo "<td>" . $row['xx'] . "</td>";
试试。
那这个格子是一行一行的吗?是不是一个完整的表格样子?是不是格子高度问题?
建议用css去调整。
貌似是高度和宽度问题
我去搜下css
css控制#table th, #table td {
padding:3px;
}<table id="table">
...
</table>
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("cbd", $con);$result = mysql_query("SELECT date,ip, count(ip) as count FROM syn_number WHERE date like '%05-08%' group by ip order by count desc limit 3");#echo "<table width='30%' height='30%' border='1' cellpadding='1' cellspacing='1'>
echo "<table><tr>
<th>date</th>
<th>ip</th>
<th>count</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['SecondName'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>我这么改了下 table大小调整合适了,不过表格里没内容 是空的
会是什么问题呢
实际上是改了 测试的
#echo "<table width='30%' height='30%' border='1' cellpadding='1' cellspacing='1'>
echo "<table>应该是
echo "<table width='30%' height='30%' border='1' cellpadding='1' cellspacing='1'>
你从数据只获得三列数据 date, ip, count 哪来的FirstName,SecondName,LastName?
不过我的sql语句得到的输出是这样的 不需要第一二三行的名字啊 有数值就可以了+------------+--------------------------------------+-------+
| date | ip | count |
+------------+--------------------------------------+-------+
| 2012-05-08 | 192.168.90.14->192.168.19.70:80 | 28356 |
| 2012-05-08 | 192.168.90.14->192.168.19.70:90 | 3939 |
| 2012-05-08 | 192.168.90.20->192.168.19.70:81 | 2844 |
+------------+--------------------------------------+-------+
{
echo "<tr>";
echo "<td>" . $row[0] . "</td>";
echo "<td>" . $row[1] . "</td>";
echo "<td>" . $row[2] . "</td>";
echo "</tr>";
}