0

I have Two Input One is

<input type="text" data-date-format="dd-mm-yyyy" class="datepicker span11" name="start_date" placeholder="Check-In Date" />

Second is

<input type="text" data-date-format="dd-mm-yyyy" class="datepicker span11" name="end_date" placeholder="Check-Out Date" />

Now The My database have two Column which is " id, start_date, end_date" and Respectively value of them is "1, 14-05-2016, 21-05-2016"

Now when i choose Form Input box "15-05-2016" as start_date And "17-05-2016" as end_date. then i get empty result. i Checked the query in sql it is shown ok. then i dump this query which shows "SELECT * FROM room_inventory WHERE start_date >= '15-05-2016' AND end_date <= '17-05-2016' "

No error came. but also don't get any result.

I tried this

 $start_date = $_POST['start_date'];
 $end_date = $_POST['end_date'];

 $checkAvailability = "SELECT * FROM room_inventory WHERE start_date >= '$start_date' AND end_date <= '$end_date' ";

 $resultAvailability = mysqli_query($con, $checkAvailability);
 $rowAvailability = mysqli_fetch_array($resultAvailability);
 rint_r($rowAvailability);

So how do i get that the input date are available in this database.

always-a-learner
  • 3,671
  • 10
  • 41
  • 81
  • @jiml Not duplicate sir, i have to find that my form data are available in database date range or not... may you don't understand what i want to say. – always-a-learner May 14 '16 at 06:46
  • What error or query output are you getting? – Tim Biegeleisen May 14 '16 at 06:48
  • @jiml sir. in that question they have only one date column in database so it's easy to find. but i have two date columns so i don't know how to find date between them. – always-a-learner May 14 '16 at 06:48
  • It would be nice to see column names and at least one row in that database. Also, you can check how that string looks like (with print("SELECT rc_type ....")) to see if there are any grammar mistakes. – Gynteniuxas May 14 '16 at 06:49
  • @TimBiegeleisen I get Empty Data. i tried this query in mysql that show empty table. and there is no error show up sir. – always-a-learner May 14 '16 at 06:50
  • I agree with what others have said. You should show us some sample data and the raw query. The empty result set may be correct for all we know. – Tim Biegeleisen May 14 '16 at 06:52
  • sir actually i have some data in my table . SELECT * FROM room_inventory WHERE start_date >= '15-05-2016' AND end_date <= '18-05-2016'; – always-a-learner May 14 '16 at 06:54
  • Like start date is 1 end date is 10 what if i have two date 3 as a start and 6 as end. so can i find that 3 & 6 are between 1 & 10. – always-a-learner May 14 '16 at 08:07
  • @EdvinTenovim I fond the answer .. and the query is "$sql = "SELECT start_date, end_date FROM room_inventory WHERE '$start_date' AND '$end_date' between '$start_date' and '$end_date'";' – always-a-learner May 14 '16 at 08:11
  • @TimBiegeleisen I fond the answer .. and the query is "$sql = "SELECT start_date, end_date FROM room_inventory WHERE '$start_date' AND '$end_date' between '$start_date' and '$end_date'";' – always-a-learner May 14 '16 at 08:11

1 Answers1

1

i think problem in query ...you can check by printing query text i think it should be :"SELECT rc_type FROM room_inventory WHERE start_date >= ".$start_date." AND end_date <= ".$end_date ." i wish it will help you :)

Mhd Wael Jazmati
  • 636
  • 9
  • 18