garfx;10927703 wrote:answer remove
$range = array();
Or move it to before the while() loop.
PS: As a courtesy to those who read your posts, please wrap your PHP code samples in [noparse]
...
[/noparse] tags. It would also help if the code were indented. Doing both of these things will make it easier for us to help.
<?php
$query = "SELECT * FROM content WHERE type = 4";
$result = mysql_query($query) or die("Error in query: $query. " . mysql_error());
$range = array(); // <--- move up here before the loop
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_object($result)) {
$start = "$row->dateLive";
$end = "$row->dateEnd";
if (is_string($start) === true) $start = strtotime($start);
if (is_string($end) === true) $end = strtotime($end);
if ($start > $end) return createDateRangeArray($end, $start);
do {
$range[] = date('Y-m-d', $start);
$start = strtotime("+ 1 day", $start);
}
while ($start < $end);
}
}