I would like to display some results (fields like name, description etc) from my database comparing a selected date with the timestamp of the rows in the database.
In my database, the field start
has this form of timestamp 2013-07-30 23:00:00
. When I search through a form, the $selected
date has the same format like 2013-07-30 13:50:00
However, I want to display results that match the same day and month, ignoring the time but I do not know how to do it using PDO statements. like comparing the 2013-07-30
only.
I have connected my database and can perform very basic queries through examples.
Thank you.
Did you try something like this?
$sh = $db->prepare('SELECT * FROM table WHERE DATE(`start`) = DATE(:start)');
$sh->bindValue(":start", $selected);
$sh->execute();
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다