Return SQL query as array
<p>The <strong>reserva_disponibilidade</strong> return the same  <strong>Array(29)</strong>, when should return...29,30, 31...
Is there a way to fix this?</p>

<pre><code>    function estoque($data, $dias, $tipo) {

        //Ajusta a data...
        $inicio = strtotime($data);
        $edia = date('d', $inicio); 
        $emes = date('m', $inicio);
        $eano = date('Y', $inicio);

        //Conecta ao db...
        $db = new DBConfig();
        $db-&gt;config();
        $db-&gt;conn();

        //Arrays
        $smarty_array = array();
        $smarty_data_array = array();

        $query_quartos = mysql_query("SELECT * FROM quartos AS quartos 
                                        INNER JOIN tipos AS tipos 
                                        LEFT JOIN reservas AS reservas 
                                        ON quartos.quarto_tipo = tipos.tipo_id
                                        AND quartos.quarto_numero = reservas.reserva_quarto_id
                                        WHERE quartos.quarto_tipo = '".$tipo."'
                                        GROUP BY quartos.quarto_id HAVING Count(*) &gt;= 1") or die(mysql_error());
        while($row = mysql_fetch_assoc($query_quartos)){
            $quartoid = $row["quarto_id"];

            while($i &lt;= $dias) {
                $today = strtotime(date('Y-m-d',mktime(0,0,0,date($emes),date($edia)+$i,date($eano))));
                $query = mysql_query("SELECT * FROM quartos AS quartos 
                              LEFT JOIN reservas AS reservas 
                              ON quartos.quarto_numero = reservas.reserva_quarto_id
                              AND ".$today." BETWEEN reservas.reserva_checkin AND reservas.reserva_checkout
                              WHERE quartos.quarto_id = '".$quartoid."'
                              GROUP BY quartos.quarto_id HAVING Count(*) &gt;= 1") or die(mysql_error());
                while($rowe = mysql_fetch_assoc($query)){
                    if (empty($rowe["reserva_status"])) {
                        $rowe["reserva_status"] = "0";
                    }
                    $smarty_data_array[] = $rowe["reserva_status"];
                }
                $i++;
            }

            $row["reserva_disponibilidade"] = $smarty_data_array;
            $smarty_array[] = $row;
        }

        $db-&gt;close();
        return $smarty_array;
    }
</code></pre>

<p>Output</p>

<pre><code>Smarty_Variable Object (3)
-&gt;value = Array (3)
  0 =&gt; Array (16)
    quarto_id =&gt; "12"
    quarto_tipo =&gt; "1"
    quarto_numero =&gt; "1"
    quarto_descricao =&gt; "Quarto padrão"
    tipo_id =&gt; "1"
    tipo_nome =&gt; "Standard"
    tipo_foto =&gt; "03f9efa3b682512c74a9275656622b03.jpg"
    reserva_id =&gt; "2"
    reserva_quarto_id =&gt; "1"
    reserva_valor =&gt; "400"
    reserva_status =&gt; "2"
    reserva_cliente_id =&gt; "58"
    reserva_checkin =&gt; "1303794000"
    reserva_checkout =&gt; "1303966800"
    reserva_obs =&gt; "Aguardando pagamento"
    reserva_disponibilidade =&gt; Array (29)
      0 =&gt; "0"
      1 =&gt; "0"
      2 =&gt; "0"
      3 =&gt; "0"
      4 =&gt; "0"
      5 =&gt; "0"
      6 =&gt; "0"
      7 =&gt; "0"
      8 =&gt; "0"
      9 =&gt; "0"
      10 =&gt; "0"
      11 =&gt; "0"
      12 =&gt; "2"
      13 =&gt; "2"
      14 =&gt; "2"
      15 =&gt; "0"
      16 =&gt; "0"
      17 =&gt; "0"
      18 =&gt; "0"
      19 =&gt; "0"
      20 =&gt; "0"
      21 =&gt; "0"
      22 =&gt; "0"
      23 =&gt; "0"
      24 =&gt; "0"
      25 =&gt; "0"
      26 =&gt; "0"
      27 =&gt; "0"
      28 =&gt; "0"
  1 =&gt; Array (16)
    quarto_id =&gt; "15"
    quarto_tipo =&gt; "1"
    quarto_numero =&gt; "5"
    quarto_descricao =&gt; "Deluxe "
    tipo_id =&gt; "1"
    tipo_nome =&gt; "Standard"
    tipo_foto =&gt; "03f9efa3b682512c74a9275656622b03.jpg"
    reserva_id =&gt; null
    reserva_quarto_id =&gt; null
    reserva_valor =&gt; null
    reserva_status =&gt; null
    reserva_cliente_id =&gt; null
    reserva_checkin =&gt; null
    reserva_checkout =&gt; null
    reserva_obs =&gt; null
    reserva_disponibilidade =&gt; Array (29)
      0 =&gt; "0"
      1 =&gt; "0"
      2 =&gt; "0"
      3 =&gt; "0"
      4 =&gt; "0"
      5 =&gt; "0"
      6 =&gt; "0"
      7 =&gt; "0"
      8 =&gt; "0"
      9 =&gt; "0"
      10 =&gt; "0"
      11 =&gt; "0"
      12 =&gt; "2"
      13 =&gt; "2"
      14 =&gt; "2"
      15 =&gt; "0"
      16 =&gt; "0"
      17 =&gt; "0"
      18 =&gt; "0"
      19 =&gt; "0"
      20 =&gt; "0"
      21 =&gt; "0"
      22 =&gt; "0"
      23 =&gt; "0"
      24 =&gt; "0"
      25 =&gt; "0"
      26 =&gt; "0"
      27 =&gt; "0"
      28 =&gt; "0"
  2 =&gt; Array (16)
    quarto_id =&gt; "26"
    quarto_tipo =&gt; "1"
    quarto_numero =&gt; "80"
    quarto_descricao =&gt; "Quarto novo "
    tipo_id =&gt; "1"
    tipo_nome =&gt; "Standard"
    tipo_foto =&gt; "03f9efa3b682512c74a9275656622b03.jpg"
    reserva_id =&gt; null
    reserva_quarto_id =&gt; null
    reserva_valor =&gt; null
    reserva_status =&gt; null
    reserva_cliente_id =&gt; null
    reserva_checkin =&gt; null
    reserva_checkout =&gt; null
    reserva_obs =&gt; null
    reserva_disponibilidade =&gt; Array (29)
      0 =&gt; "0"
      1 =&gt; "0"
      2 =&gt; "0"
      3 =&gt; "0"
      4 =&gt; "0"
      5 =&gt; "0"
      6 =&gt; "0"
      7 =&gt; "0"
      8 =&gt; "0"
      9 =&gt; "0"
      10 =&gt; "0"
      11 =&gt; "0"
      12 =&gt; "2"
      13 =&gt; "2"
      14 =&gt; "2"
      15 =&gt; "0"
      16 =&gt; "0"
      17 =&gt; "0"
      18 =&gt; "0"
      19 =&gt; "0"
      20 =&gt; "0"
      21 =&gt; "0"
      22 =&gt; "0"
      23 =&gt; "0"
      24 =&gt; "0"
      25 =&gt; "0"
      26 =&gt; "0"
      27 =&gt; "0"
      28 =&gt; "0"
-&gt;nocache = false
-&gt;scope = "Smarty root"
</code></pre>
