2016-04-08 11 views
-1

Veri tabanından veri alan ve görüntüleyen bir komut dosyası yazıyorum. 'a yalnızca her sayfada belirli bir tarihten, bir html giriş formu tarafından tanımlanan tarihin verilerini göstermeliyim. Kodlara bir bakın.Belirli bir tarihten itibaren mysqli tablo tablolarını al

 }else{ 
     //date selector - this chooses which date to display the data. The output of this needs to 
    be what date the data is sorted by. 
     $date = date('Y-m-d'); 
     echo " 
     <input type='date' name='date' value='$date'>"; 
     //include the database connection so you can fetch data from the table 'notices' 
     include("db.php"); 
     //sql fetching data from the database ad displaying it 
//Each row of data is currently sorted by the field id, which is currently auto-incrementing 
     $sql = "SELECT * FROM notices ORDER BY id DESC"; 
     $stmt = $db->query($sql); 
     $stmt->execute(); 
     $stmt->setFetchMode(PDO::FETCH_ASSOC); 
      if($stmt->rowCount() > 0){ 
       while($row = $stmt->fetch()){ 
       echo " 
       <p><b>".$row['subject']."</b></p> 
       <p>".$row['message']."</p> 
       <p>".$row['name']."<br></p> 
       <hr> 
       "; 
       } 
      } 
     } 

Herhangi bir yardım en çok takdir edilecektir. Teşekkürler.

+0

kullanım tarihi parametresi görüntülemek için mysqli sorgusu kullanabilirsiniz nerede fıkra –

+0

nedir şema? – symcbean

cevap

0

Eğer veritabanından veri böyle basit bir kod

if ($result = mysqli_query($link, "SELECT date FROM database where date = your html form input date")) { 
    printf("Select returned %d rows.\n", mysqli_num_rows($result)); 

    /* free result set */ 
    mysqli_free_result($result); 
} 
+0

OP, MySQLi_ API'sini değil, PDO'yu burada kullanıyor. –

+0

tamam bu bağlantıyı kullan http://php.net/manual/en/mysqli.query.php –

İlgili konular