Php 带有数据库值的HTML表
我已经用数据库值创建了一个HTML表Php 带有数据库值的HTML表,php,mysql,html-table,Php,Mysql,Html Table,我已经用数据库值创建了一个HTML表 <?php include 'conexao.php'; echo "<div id='table'> <table > <tr> <th class='first'>Selecione</th> <th>Mês</th> <th>Valor&
<?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>";
?>
对于像您这样的情况,我通常使用php分页。我想如果你想这样做,下面的链接将帮助你
考虑在数据库中执行此操作(SQL Server语法):
DECLARE@tmpSearch表(
行数整数标识(0,1),
名称VARCHAR(4000)
)
插入@tmpSearch
执行[dbo].[spSearch]
@搜索词
选择*
来自@tmpSearch
其中RowNumber>=(@PageNo-1)*@PageSize
和行号<(@PageNo*@PageSize)
按行号排序
@tmpSearch
需要与[dbo].[spSearch]
相同的列以及行数
列我认为您需要在php中分页
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