0

Ok I am using a script i found on http://davidwalsh.name/php-calendar for creating an managing a calendar. Currently I have reached the point were we are to query the database for events.

   /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !!  IF MATCHES FOUND, PRINT THEM !! **/

 $fulldate = strtotime("$month/$list_day/$year");

 mysql_select_db($database_dbconnect, $dbconnect);
 $query_cal = "SELECT * FROM calendar WHERE startdate > '$fulldate' AND enddate < '$fulldate' AND status = '1' ORDER BY eventtime DESC";
 $caldetails = mysql_query($query_cal, $dbconnect) or die(mysql_error());
 $cal = mysql_fetch_assoc($caldetails);

Now I have my events in an array. The next line im presented with is

  $calendar.= str_repeat('',1);

Now I'm not understanding how im supposed to get my events into that line?I tried using a do or while loop but everything fails. How do I get my array into the str_repeat?

4

1 回答 1

0

str_repeat() 仅用于存根。您可能应该编写如下内容:

while ($cal = mysql_fetch_assoc($caldetails)) {
    $calendar .= "<p>" . $cal['eventtime'] . ' — ' . $cal['title'] . "</p>";
}

顺便说一句,检查您的 SQL 查询。对我来说,它似乎总是返回零结果,它可能应该是这样的

$fulldate_tomorrow = $fulldate+86400;
$query_cal = "SELECT * FROM calendar WHERE startdate >= '$fulldate' AND enddate < '$fulldate_tomorrow' AND status = '1' ORDER BY eventtime DESC";
于 2013-07-09T11:33:04.103 回答