php - How can i get a value between two date from database? -


I am making an application for hotel booking

  public function GetMarriageDate () { $ Frm = $ this- & gt; Input-> ('From') post; $ From = $ this- & gt; Input-> Post ('to'); $ Date = $ this- & gt; Db- & gt; Query (`$ frm 'and' 'between' SELECT * FROM` tbl_marriagebooking 'WHERE (' $ frm 'and' from $ copy ') from UNIONSELECT * to' tbl_marriagebooking 'WHERE ();); $ Count = $ date- & gt; Num_rows (); Return $ count; }  

My database table (tbl_marriageBooing)

  ID name to_date from_date 1 name 1 2014-11-15 2014- 11 -18 2 Name 2 2014-11-20 2014-11-24 3 Name 3 2014-11-26 2014-11-30  

My problem is that if any one date < In this situation, the SQL Returns or Selection code 2 = 2 because 2014- 11 -20 to 2014-11-24 has been booked.

Try

  $ frm = date ('YM-D ', Stratotel ($ this-> Input-> Post (' to '))); $ From = date ('wi-m-d', stratimime ($ this-> input- & gt; post ('to')); $ Date = $ this- & gt; Db- & gt; Query ("SELECT * FROM tbl_marriagebooking Where to Date (to_date)> = '$ sec' and DATE (from_diet) & lt; = '$ frm'"); For both exact date matches,  
  $ date = $ this- & gt; Db- & gt; Query ("SELECT * FROM tbl_marriagebooking where date (to_date) = '$ sec' and DATE (to _date) = '$ frm'");  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -