用查询结果制作一个表php

时间:2017-03-03 11:36:06

标签: php

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

这是我的代码,我想更新它,如果有人可以帮助我,我会感激。

CODE:

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

1 个答案:

答案 0 :(得分:0)

这是一个关于如何echo phphtml table

结果的示例
<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>
相关问题