2017-03-03 57 views
0

我要让两个日期之间的选择,然后呼应,结果这样的形象the image制作表查询PHP的结果

这是我的代码,我想将其更新到这一点,如果有人可以帮助我,我会很感激。

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

你的问题实在是不明确的例子。尽量做到简单易懂,所以我们可以帮助 –

+0

我想要选择从我多少信息有2日期间,然后将其安排在这样的 –

回答

0

这是你如何能echophp结果与html 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> 
+0

好,谢谢表我的数据库表,但是想象一下,我想呼应该搜索为每个门户 –

+0

使用'while'循环到你的数据库 –

+0

ü可以编辑你的答案''每次的row'的mysqli_fetch_assco'的结果来解释吗?感谢和抱歉,您所浪费的时间 –