Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

bagaimana menghasilkan laporan antara dua tanggal menggunakan datepicker,ajax,php,mysql.?

I have Created Whole Tutorial for Date Wise Report, so once try it

Struktur tabel

CREATE TABLE IF NOT EXISTS `bookings` (
  `id` int(12) NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `start` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `phone` varchar(20) NOT NULL,
  `comments` longtext NOT NULL,
  `approved` varchar(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

INSERT INTO `bookings` (`id`, `date`, `start`, `name`, `email`, `phone`, `comments`, `approved`) VALUES
(1, '2014-12-17', 'yes', 'Mahendra', '[email protected]', '89XXXXXXXX', 'nothing', 'yes'),
(2, '2014-12-18', 'no', 'Rahul', '[email protected]', '987XXXXXXX', 'very nice article', 'yes');

my_test.php

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#generate_report").click(function(){
	  var from_date=jQuery("#fromdate").val();
	  var to_date=jQuery("#todate").val();
	  var data =
	  {		
	  	from_date	 : from_date,
		to_date		 : to_date
	  }
	jQuery.ajax({	
					type: "POST",
					url: "test.php",
					data: data,
					success: function(responce){
						$("#txtHint").after(responce);
				  }	
			 });
  });
});
</script>
From date: <input type="text" id="fromdate" value="2014-12-17">   To date: <input type="text" id="todate" value="2014-12-18">  
<input type="button" name="generate_report" id="generate_report" value="Generate Report" />
<br>
<div id="txtHint"><b>User informations will be listed here.</b></div>

test.php (file panggilan ajax)

<?php
error_reporting(0);
include_once("wp-config.php");
extract($_POST);
$sql1=mysql_query("Select * from bookings where date between '".$from_date."' AND '".$to_date."'");
echo "<table border='1'>
	  <tr>
		<th>id</th>
		<th>date</th>
		<th>start</th>
		<th>name</th>
		<th>email</th>
		<th>phone</th>
		<th>comments</th>
		<th>approved</th>
	 </tr>";
		while($row = mysql_fetch_array($sql1))
		{
		  echo "<tr>";
			  echo "<td>" . $row['id'] . "</td>";
			  echo "<td>" . $row['date'] . "</td>";
			  echo "<td>" . $row['start'] . "</td>";
			  echo "<td>" . $row['name'] . "</td>";
			  echo "<td>" . $row['email'] . "</td>";
			  echo "<td>" . $row['phone'] . "</td>";
			  echo "<td>" . $row['comments'] . "</td>";
			  echo "<td>" . $row['approved'] . "</td>";
		  echo "</tr>";
		}
echo "</table>";
?>

demo ini berfungsi dengan baik dan baru saja saya buat jadi sekali periksa...

Tolong Siapapun yang tertarik daripada tolong perbaiki jawaban dan berikan suara untuk solusi ini..Terima kasih



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Bagaimana cara menarik data dari database MySQL ke dalam stylesheet di file/foldernya sendiri?

  2. Temukan baris yang memiliki nilai yang sama pada kolom di MySQL

  3. Ringkasan catatan detail MySQL yang cocok dengan rentang alamat IP - diperlukan mySQL Jedi Knight

  4. Memigrasikan Google Cloud SQL untuk MySQL ke Server Lokal

  5. Cara SUM dari MySQL untuk setiap n record