使用php查询结果生成表
我想在两个日期之间做一个选择,然后像图中那样回显结果 这是我的代码,我想更新它,如果有人能帮助我,我将不胜感激 代码:使用php查询结果生成表,php,Php,我想在两个日期之间做一个选择,然后像图中那样回显结果 这是我的代码,我想更新它,如果有人能帮助我,我将不胜感激 代码: 这是一个关于如何使用html表echophp结果的示例 <table> <thead> <th>Portal</th> <th>Results</th> </thead> <tbody> <?php $dataini = mysq
这是一个关于如何使用html表echo
php
结果的示例
<table>
<thead>
<th>Portal</th>
<th>Results</th>
</thead>
<tbody>
<?php
$dataini = mysqli_real_escape_string($link, $_POST['field2']);
$dataini = date('Y-m-d', strtotime(str_replace('-', '/', $dataini)));
$datafim = mysqli_real_escape_string($link, $_POST['field3']);
$datafim = date('Y-m-d', strtotime(str_replace('-', '/', $datafim)));
$query = mysqli_query($link, "SELECT * FROM conteudo where d_datapub between '$dataini' and '$datafim'");
$todos = mysqli_num_rows($query);
while ($row = mysqli_fetch_assoc($query)) {
$portalname = $row['portalname'];//name of database table column with the portal name
$portalresult = $row['portalresult'];
echo "<tr>";
echo "<td>" .$portalname"</td>";
echo "<td>" .$portalresult"</td>";
echo "</tr>";
?>
</tbody>
</table>
门户
结果
你的问题真的不清楚。尽量让它简单易懂,这样我们就可以提供帮助我想从我的数据库表中选择我在两个日期之间有多少信息,然后将其组织在这样的表中好的,谢谢,但是想象一下,我想回显每个portalUse a的搜索结果,而循环到数据库中每个行的mysqli\u fetch\u assco
,你能编辑你的答案来解释我吗?感谢并为您浪费的时间表示歉意。结果不是一个数据库字段,它是数据库在两个日期之间的行数。在echo
表的该部分,它是$tdos
<html>
<link rel="stylesheet" type="text/css" href="../css/pesquisa.css">
<div class="well-searchbox">
<form action="" class="form-horizontal" method="post" role="form">
<div class="form-group">
<label class="col-md-4 control-label">Portais</label>
<div class="form-group">
<label class="col-md-4 control-label">Data Inicio</label>
<div class="col-md-8">
<input type="text" readonly name="field2" id="field2" alt="Data de Nascimento" class="IP_calendar" title="Y/m/d" style="width:200px;" placeholder="Ano-Mes-Dia">
</div>
<div class="form-group">
<label class="col-md-4 control-label">Data Fim</label>
<div class="col-md-8">
<input type="text" readonly name="field3" id="field3" alt="Data de Nascimento" class="IP_calendar" title="Y/m/d" style="width:200px;" placeholder="Ano-Mes-Dia">
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-5">
<button type="submit" name="contardata" class="btn btn-primary">Contar</button>
</div>
</html>
<table>
<thead>
<th>Portal</th>
<th>Results</th>
</thead>
<tbody>
<?php
$dataini = mysqli_real_escape_string($link, $_POST['field2']);
$dataini = date('Y-m-d', strtotime(str_replace('-', '/', $dataini)));
$datafim = mysqli_real_escape_string($link, $_POST['field3']);
$datafim = date('Y-m-d', strtotime(str_replace('-', '/', $datafim)));
$query = mysqli_query($link, "SELECT * FROM conteudo where d_datapub between '$dataini' and '$datafim'");
$todos = mysqli_num_rows($query);
while ($row = mysqli_fetch_assoc($query)) {
$portalname = $row['portalname'];//name of database table column with the portal name
$portalresult = $row['portalresult'];
echo "<tr>";
echo "<td>" .$portalname"</td>";
echo "<td>" .$portalresult"</td>";
echo "</tr>";
?>
</tbody>
</table>