Question : How to push mysql result into php array

I'm making an availability calendar with MySQL and PHP, and I'm making the following query to find out on which dates a specific apartment is reserved.

$sql = "SELECT booking_date FROM apartment_booking_date WHERE apartment_id='$apartment_id' AND ap_booking_id is not null";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
      $reserved_dates[]=$row;
}

The query returns the correct dates, but when I'm trying to check, if the active date is included in the array of reserved dates, but the condition isn't working. Here's how my condition looks like:

if(in_array($date_db_format,$reserved_dates))

I think that the reason for this failing is probably in the format of my $reserved_dates array. This is how it looks like, when I take a dump of it. The dates are correct, but I'm having arrays inside arrays, while I think, that in order for my condition to work, the arrays shouldn't be nested.

Array ( [0] => Array ( [0] => 2010-05-01 [booking_date] => 2010-05-01 ) [1] => Array ( [0] => 2010-05-02 [booking_date] => 2010-05-02 ) [2] => Array ( [0] => 2010-05-03 [booking_date] => 2010-05-03 ) [3] => Array ( [0] => 2010-05-04 [booking_date] => 2010-05-04 ) [4] => Array ( [0] => 2010-05-10 [booking_date] => 2010-05-10 ) [5] => Array ( [0] => 2010-05-11 [booking_date] => 2010-05-11 ) [6] => Array ( [0] => 2010-05-12 [booking_date] => 2010-05-12 ) [7] => Array ( [0] => 2010-05-13 [booking_date] => 2010-05-13 ) [8] => Array ( [0] => 2010-05-14 [booking_date] => 2010-05-14 ) [9] => Array ( [0] => 2010-05-15 [booking_date] => 2010-05-15 ) )

Answer : How to push mysql result into php array

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
What if you change

while ($row = mysql_fetch_array($result)) {
      $reserved_dates[]=$row;
}

to

while ($row = mysql_fetch_array($result)) {
      $reserved_dates[]=$row[0];
}
Random Solutions  
 
programming4us programming4us