I'm having some trouble with displaying a list of some MySQL results. Does anyone know what I might be doing wrong? I seems to me like it should work, but apparently I've got something wrong.
It's supposed to select unique events (as some of them are duplicated) from a calendar, then display them in a list.
I'm getting an invalid mysql result resource error and an invalid argument for foreach(), however I think the foreach() error will go away when the sql error is fixed. Thats an assumption though.
Any help? Thanks.
<?php
echo '<b>Events</b><br>';
$query = "SELECT DISTINCT show FROM calendar ORDER BY caldate LIMIT 10";
$result = mysql_query($query);
$event = mysql_fetch_array($result);
foreach ($event as $element){
echo $element . '<br>';
}
?>