繁体   English   中英

用查询PHP的结果制作表格

[英]Making a table with result of a query php

我想在2个日期之间进行选择,然后回显此图像中的结果 图片

这是我的代码,我想将其更新为只要有人可以帮助我,我将不胜感激。

码:

<?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); 
                    echo $todos;
?>

HTML

 <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>

这是一个有关如何使用html table 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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM