Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
aih, seguinte, fiz esse calendario que marca eventos, blza.. ateh q to indo bem, a naum ser por um little problem, ele soh cata um evento sendo q tem 3 o_O
deem uma olhada no scrip:
PHP
[*]$Now = getdate();
[*]$MDay = $Now['mday'];
[*]$WDay = $Now['wday'];
[*]$Month = $Now['mon'];
[*]$Year = $Now['year'];
[*]
[*]$isBiYear = ($Year%4) == 0 ? 1 : 0 ;
[*]$MTDs = Array(31, $isBiYear > 0 ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
[*]$MonthDays = $MTDs[$Month - 1];
[*]
[]/ getting the initial week day */
[*]$StartDay = $WDay;
[*]for($x = $MDay; $x > 1; $x--) {
[*] if($StartDay < 0) {$StartDay = 6;}
[*] $StartDay--;
[*]}
[*]
[]/ letting empty colums with another month's days */
[*]$Empties = $StartDay - 1;
[*]for($x = 0; $x < $StartDay; $x++) {
[*] print("\n<td> </td>");
[*]}
[*]
[]/ looking for events scheduleds */
[*]$Link = mysql_connect("***", "***", "***") or die(mysql_error());
[*]mysql_select_db("blog") or die(mysql_error());
[*]
[]$Query = mysql_query("SELECT FROM events") or die(mysql_error());
[*]while($Row = mysql_fetch_array($Query)) {// 0 -> UID, 1 -> Label, 3 -> Day
[*] $E[$Row[0]]["Day"] = $Row[3];
[*] $E[$Row[0]]["Label"] = $Row[1];
[*]}
[*]mysql_close($Link);
[*]
[]/ setting today as an event */
[*]$E[0]["Day"] = $MDay;
[*]$E[0]["Label"] = "today.";
[*]
[]/ start to write each day */
[*]$WDay = $StartDay;
[*]for($Day = 1; $Day <= $MonthDays; $Day++) {
[*] if($WDay > 6) {print("\n</tr>\n<tr>"); $WDay = 0;}
[*] for($i = 0; $i < count($E); $i++) {
[*] if($Day == $E[$i]["Day"]) {$toPrint = "\n<td><a href=\"?Schedule=".$i."\" title=\"".$E[$i]["Label"]."\">".$Day."</a></td>";}
[*] else {$toPrint = "\n<td>".$Day."</td>";}
[*] }
[*] print($toPrint);
[*] // => "<td>".$Day."</td>"
[*] $WDay++;
[*]}
ja tentem colocar manualmente a array de eventos, ja fiz varios testes, ele ta pegando do mysql, mas ele soh marca o ultimo encontrado =/
antes que me perguntem, sim, sou fresco e escrevo os comentarios em ingles :)
valew [][]'s
Carregando comentários...