如题 想做个简单的查询系统:
现在搞了个没有表单的,代码如下:
<?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文件了?

解决方案 »

  1.   

    那么你需要一个提交数据的地方。不一定非要再弄一个提交数据的表单,用Url后面GET传值也可以。
      

  2.   

    $limit = ' LIMIT ' . $_POST['start'] . ',' . $_POST['end'];$sql = "SELECT date,ip,  count(ip) as count FROM syn_number WHERE date like '%05-08%' group by ip order by count desc $limit";$result = mysql_query($sql);
    -----------htmlLimit:
    <input type="text" name="start" />
    <input type="text" name="end" />
      

  3.   

    如果是开放系统要注意POST过滤什么的,要考虑安全问题 
      

  4.   

    表格头有3个th而下面只有2个td。对应不上了。
    再加一行
     echo "<td>" . $row['xx'] . "</td>";
    试试。
      

  5.   

    3个 <th> 对应两个<td>  不符合标准。
      

  6.   

    加了还是聚在一起 很小的格子???
    那这个格子是一行一行的吗?是不是一个完整的表格样子?是不是格子高度问题?
    建议用css去调整。
      

  7.   

    是一行一行的 是一个完整表格
    貌似是高度和宽度问题 
    我去搜下css 
      

  8.   

    那就是样式没弄好。。给table加个id
    css控制#table th, #table td {
        padding:3px;
    }<table id="table">
    ...
    </table>
      

  9.   

    csdn不是我们手懒的工具。我们回答你问题是帮你解决问题,找到出错在哪儿。给你的是思想,解决问题的办法而不是几行代码。千万别一个粘贴 复制就完了。不去想为什么,那就没多大意义了。
      

  10.   


    <?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大小调整合适了,不过表格里没内容 是空的
    会是什么问题呢
      

  11.   

    注释那行地方忘了改  
    实际上是改了 测试的
    #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'>
      

  12.   

    SELECT date,ip,  count(ip) as count FROM syn_number
    你从数据只获得三列数据  date, ip, count 哪来的FirstName,SecondName,LastName?
      

  13.   

    搜了下  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 |
    +------------+--------------------------------------+-------+
      

  14.   

    while($row = mysql_fetch_array($result))
      {
      echo "<tr>";
      echo "<td>" . $row[0] . "</td>";
      echo "<td>" . $row[1] . "</td>";
      echo "<td>" . $row[2] . "</td>";
      echo "</tr>";
      }