Spaksu Spaksu - 1 month ago 23
MySQL Question

SELECT * FROM dblist WHERE date?

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?

rai rai
Answer

It should be

$newdate = date('Y-m-d', strtotime($pickeddate)); 
$result = mysql_query('SELECT * FROM dblist WHERE dateandtime LIKE  "'.$newdate.'%"  ');