-1

I want to get the date in mysql using input type="date" .. please help for the code...

here is my code:

<form action="sales.php" method="get">
  <input type="date" name="d1" value="" required="required" />
  <input id="btn" type="submit" value="Search">
</form>

Here is my connection:

<?php 
  if (isset($_GET[ "d1"])) { 
    $do=$_GET[ "d1"]; 
  } else { 
    $do=0;
  }; 
  $result=$ db->prepare("SELECT * FROM sales WHERE date=:a");
  $result->bindParam(':a', $do); 
  $result->execute(); 
  for($i=0; $row = $result->fetch(); $i++){ 
?>

Thanks in advance

1 Answers1

0

Inside that sales.php script print out:

$date_value =  $_GET['d1'];
echo $date_value;

$myslq_date = date ('Y-m-d H:i:s', strtotime ($date_value));

But check for browser compatibility for that input type - not sure how it's supported.

MilanG
  • 6,994
  • 2
  • 35
  • 64