sql >> Databasteknik >  >> RDS >> Mysql

hur genererar rapporten mellan de två datumen med datepicker,ajax,php,mysql.?

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

Tabellstruktur

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 (ajax-anropsfil)

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

den här demon fungerar perfekt och jag har nyss skapat så en gång kolla det...

Snälla vem som helst får intresse än vänligen rätta svaret och ge röst för denna lösning..Tack



  1. hur man prefix en sträng före sekvens genererad av postgresql?

  2. MySql varchar ändring från Latin1 till UTF8

  3. BIN_TO_NUM() Funktion i Oracle

  4. uppdatera och komprimera SQLite-databas i Android