【问题标题】:HTML table with database values [closed]具有数据库值的 HTML 表 [关闭]
【发布时间】:2018-06-28 22:45:38
【问题描述】:

我创建了一个包含数据库值的 HTML 表

<?php
include 'conexao.php';
echo "<div id='table'>
      <table >
          <tr>
              <th class='first'>Selecione</th>
              <th>Mês</th>
              <th>Valor</th>
          </tr>";
$result = mysql_query('SELECT * FROM cpf');
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
while($row = mysql_fetch_array( $result )) {
    echo "<tr>
              <td class='first'><input type='radio' name='selecione'/></td>
              <td>". $row['mes'] ."</td>
              <td>". number_format($row['valor'], 2, ',', '.') ."</td>
          </tr>";
} 
echo "</table></div>";
?>

嗯,它很好用,但是当我有很多值时,我必须向下滚动页面。例如,当我有超过 10 个值时,我想为我的表创建“页码”。

类似这样的:http://www.phpgrid.org/demo-center/

观察:我不想像链接中的表格那样完成表格,因为我想将我的样式应用于表格......

有人可以帮我吗?

【问题讨论】:

  • 我认为你需要在 php 中进行分页

标签: php mysql html-table


【解决方案1】:

对于像你这样的情况,我通常使用 php 分页。我想如果你想这样做,下面的链接会帮助你。

http://www.tutorialspoint.com/php/mysql_paging_php.htm
http://www.developphp.com/page.php?id=289

问候

【讨论】:

    【解决方案2】:

    在数据库中执行(SQL-Server 语法):

    DECLARE @tmpSearch TABLE (  
            RowNumber INT IDENTITY(0,1),
            Name VARCHAR(4000)
    )
    
    
    INSERT @tmpSearch 
    EXEC [dbo].[spSearch]
    @SearchTerm
    
    SELECT * 
    FROM @tmpSearch 
    WHERE RowNumber >= (@PageNo-1) * @PageSize 
    AND RowNumber < (@PageNo * @PageSize)  
    ORDER BY RowNumber
    

    @tmpSearch 需要与 [dbo].[spSearch]RowNumber 列相同的列

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-31
      • 2016-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多