[thelist] php array

Mark Groen evolt at markgroen.com
Mon Nov 21 10:00:02 CST 2005


Getting a couple columns from the database with event dates in
2005-11-29 format, and would like to display the result with each new
month showing the month and day, just for the first event of that month
and the rest of the days in the month showing just the days.

Got errors first: "Passed variable is not an array or object", referring
to the next() and current() functions.

while($row = mysql_fetch_array($eventList))
{ $title = $row[0];
$event_date = $row[1];

if( list($title,$event_date) = mysql_fetch_array($eventList) )
{ $event_time = explode("-", $event_date); //2005-11-18

if( current($a) < next($a))
{echo "$event_time[1]" . " $event_time[2]" . " $title" . ""; }
echo "$event_time[2]" . " $title" . " ";
}
}
So tried this which gets me closer it seems, but still not getting that
first listing of the month to display it once.

while($row = mysql_fetch_array($eventList))
{ $title = $row[0]; $event_date = $row[1];

 $event_time = explode("-", $event_date); // 2001-11-29
 $thisdate = strtotime($event_date);

 $num_rows = mysql_num_rows($eventList);
 $a = array_fill(1, 1, $event_time[1]);

#print_r($a)  . "\n";
if( next($a) > current($a) )
  { echo date('F',$thisdate) .  date('j',$thisdate) . " " . $title .
"<br />";
  } else {echo  date('j',$thisdate) . " " . $title . "<br />";}
}

something simple I don't understand surely, any clarity appreciated!

cheers,

        Mark




More information about the thelist mailing list