-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

4
  • What does var_export($do); show? Commented Mar 24, 2015 at 14:33
  • already edit. please check again the codes thanks Commented Mar 24, 2015 at 14:34
  • possible duplicate of Inserting Date from form using PHP Mysql Commented Mar 24, 2015 at 14:34
  • Your edit did not answer my question Commented Mar 24, 2015 at 14:34

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.