2017-03-03 59 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'的結果來解釋嗎?感謝和抱歉,您所浪費的時間 –