I have my date from my date input : 20-10-2016
echo "<form method='post' action='rapor.php'>";
echo "<input type='date' name='pickdate' value=".date("Y-m-d")."> <input type='submit' value='Git'>";
echo "</form>";
$pickeddate = strtr($_POST['pickdate'], '/', '-');
echo date('Y-m-d', strtotime($pickeddate));
And result of this : 2016-10-20
So far so good..
I need to show only rows date i have picked.
+------+-------------+---------------------+
| name | mail | dateandtime |
+------+-------------+---------------------+
| AAA | a@a.com | 2016-04-20 06:44:19 |
| BDC | b@c.com | 2016-10-21 06:44:19 |
| CDD | c@d.com | 2016-04-10 06:44:19 |
| EED | e@d.com | 2016-10-20 06:44:19 |
| SAS | a@s.com | 2016-04-10 06:44:19 |
+------+-------------+---------------------+
thats my result code but....
$result = mysql_query('SELECT * FROM dblist WHERE ('$pickeddate%') ');
why not working?
It should be
$newdate = date('Y-m-d', strtotime($pickeddate));
$result = mysql_query('SELECT * FROM dblist WHERE dateandtime LIKE "'.$newdate.'%" ');
Where is your field name?
Try this
$result = mysql_query('SELECT * FROM dblist WHERE dateandtime LIKE ('$pickeddate%') ');
Try this:
$pickeddate = date('Y-m-d', strtotime($_POST['pickdate']));
SELECT * FROM dblist WHERE date(dateandtime) LIKE '$pickeddate%';
You have to specify column name to do condition with as,
$result = mysql_query('SELECT * FROM dblist WHERE dateandtime LIKE "'.$pickeddate.'%" ');
You can also try below query for your expected result
$newdate = date('Y-m-d', strtotime($pickeddate));
$result = mysql_query('SELECT * FROM dblist WHERE DATE(dateandtime) = "'.$newdate.'"');
This will be compare exact date.