Ir para conteúdo
Fórum Script Brasil
  • 0

Se Tiver Evento, Destaca No Calendario


Guest Lukas

Pergunta

Eu tenho um calendario normal q marca o dia atual e tudo, só q eu queria o seguinte, q qando tivesse algum evento no banco ele marcasse com um background na <td>, no calendario q eu tenho eu consigo fazer isto colocando um elseif , mais eu queria q isto acontecesse automaticamente. alguém sabe como fazer isto?

Obrigado

Link para o comentário
Compartilhar em outros sites

10 respostass a esta questão

Posts Recomendados

  • 0

da uma condição (if) para quando tiver um evento no dia ele colocar...

faz uma comparação...

if($event == $dia){echo "<td b...";

}

Link para o comentário
Compartilhar em outros sites

  • 0

beleza, oh, o codigo é meio grandinho cara, mais eu vou postar só a parte do calendario, beleza?

<table border="<?php print $tbd; ?>" cellpadding="<?php print $tcp; ?>" cellspacing="<?php print $tcs; ?>" width="<?php print $dbw * 7; ?>">

    <tr>

      <td class="CalendarTitle">

<?php

print "$month[$current_month] $current_year";

?>

      </td>

    </tr>

  </table>

  <table border="<?php print $tbd; ?>" cellpadding="<?php print $tcp; ?>" cellspacing="<?php print $tcs; ?>" width="<?php print $dbw * 7; ?>">

   

  <tr>

    <?php

  //Loop through days of the week and display the short names above the columns in the calendar

  for ($i=0;$i<7;$i++) {

    print "      <td width=\"$dbw\" height=\"$wbh\" class=\"WeekdayTitle\">$week[$i]</td>\n";

  }

?>

  </tr>

  <?php

  //Set the day counter to the first day, 1.

  $day_counter = 1;

  //This line continues running the loop until all the days of the month have been displayed.

  while($day_counter <= $days_in_month) {

    print "  <tr>\n";

    //Loop through the days of the week to display each day number.

    for($i = 0; $i < 7; $i++) {

      //This line makes sure that a day should be drawn on this particular calendar spot.

  //To draw a day for this spot, there must be one of two cases true:

  // 1 - The day counter is still within the amount of days for this month and the first

  //day is not set to 0 and the first day is set to this spot.

  // 2 - The day counter is still within the amount of days for this month and the first

  //day is equal to 0.

  if ((($day_counter <= $days_in_month) && ($first_day != 0) && ($first_day == $i)) || (($day_counter <= $days_in_month) && ($first_day == 0))) {

        //check to see if the current day counter is today's day

  if (($day_counter == $current_day) && (!$mt)) {

        print "      <td width=\"$dbw\" height=\"$dbh\" class=\"MarkDay\">$day_counter</td>\n";

  }

  else {

        print "      <td width=\"$dbw\" height=\"$dbh\" class=\"NormalDay\">$day_counter</td>\n";

  }

        //Resetting first_day tells us that the first day of the month has already been drawn.

        $first_day = 0;

        $day_counter++;

      }

      else {

    //No day number should be drawn on this calendar spot, therefore draw a blank spot.

        print "      <td width=\"$dbw\" height=\"$dbh\" class=\"BlankDay\">&nbsp;</td>\n";

      }

    }

    print "  </tr>\n";

  }

?>

Link para o comentário
Compartilhar em outros sites

  • 0

Fica aqui para uso da galera...

Arquivo config.php

//crie uma pasta evento dentro do diretorio que você colocara os arquivos da agenda...

<?

// CRIE UMA PASTA EVENTO E CHMOD 777

$path_evento = "COLOCA A PATH PARA A PASTA EVENTO SEM BARRA NO FINAL";

$url_evento = "http://www.seusite.com.br/agenda/evento";

?>

Agoara o arquivo cadastra_evento.php

<?

include("config.php");

?>

<html>

<head>

<title>Formul&aacute;rio para publica&ccedil;&atilde;o de eventos</title>

<link href="estilo.css" rel="stylesheet" type="text/css"></head>

  <?php

  if ($acao=="gravar")

  {

    if (file_exists("$path_evento/$dia$mes$ano.php")) {

$mensagens_antigas=join ('', file ("$path_evento/$dia$mes$ano.php")); }

$mensagem_nova="<title>Evento</title><link href=estilo.css rel=stylesheet type=text/css><b>Evento:</b> $evento \n <br><b>Data:</b> $dia/$mes/$ano <br>\n <b>Atração:</b> $atracao <br> \n <b>Local:</b> $local <br> \n <b>Descrição:</b> $descricao <br> \n <b>Quem convida:</b> $quemconvida <br> \n <b>Telefone:</b> $telefone <br> \n <b>E-mail:</b> <a href=mailto:$email>$email</a> <br> \n <center><a href=javascript:window.close()>Fechar janela</a></center><hr size=1 color=black> \n <br>";

    $mensagens_atuais="$mensagem_nova\n$mensagens_antigas";

    $fp = fopen ("$path_evento/$dia$mes$ano.php", "w+");

    fwrite ($fp, $mensagens_atuais);

    fclose ($fp);

    echo "<p align=center>Cadastro efetuado com sucesso!!!</p>

<p align=center>Utilize o formulário novamente se deseja cadastrar outro evento.</p>

";

  };

?>

<body>

<form action="" method="post" name="eventos">

  <table width="50%" border="0" align="center">

    <tr>

      <td width="27%"><p>Evento:</p>

      </td>

      <td width="73%"><input name="evento" type="text" id="evento" size="50"></td>

    </tr>

    <tr>

      <td width="27%">Data:</td>

      <td width="73%"><select name="dia" id="dia">

      <option value="1">01</option>

      <option value="2">02</option>

      <option value="3">03</option>

      <option value="4">04</option>

      <option value="5">05</option>

      <option value="6">06</option>

      <option value="7">07</option>

      <option value="8">08</option>

      <option value="9">09</option>

      <option value="10">10</option>

      <option value="11">11</option>

      <option value="12">12</option>

      <option value="13">13</option>

      <option value="14">14</option>

      <option value="15">15</option>

      <option value="16">16</option>

      <option value="17">17</option>

      <option value="18">18</option>

      <option value="19">19</option>

      <option value="20">20</option>

      <option value="21">21</option>

      <option value="22">22</option>

      <option value="23">23</option>

      <option value="24">24</option>

      <option value="25">25</option>

      <option value="26">26</option>

      <option value="27">27</option>

      <option value="28">28</option>

      <option value="29">29</option>

      <option value="30">30</option>

      <option value="31">31</option>

      </select> <select name="mes" id="mes">

      <option value="Janeiro">Janeiro</option>

      <option value="Fevereiro">Fevereiro</option>

      <option value="Mar&ccedil;o">Mar&ccedil;o</option>

      <option value="Abril">Abril</option>

      <option value="Maio">Maio</option>

      <option value="Junho">Junho</option>

      <option value="Julho">Julho</option>

      <option value="Agosto">Agosto</option>

      <option value="Setembro">Setembro</option>

      <option value="Outubro">Outubro</option>

      <option value="Novembro">Novembro</option>

      <option value="Dezembro">Dezembro</option>

      </select> <select name="ano" id="ano">

          <option value="2005">2005</option>

          <option value="2006">2006</option>

        </select></td>

    </tr>

    <tr>

      <td>Hor&aacute;rio:</td>

      <td><input name="atracao" type="text" id="atracao" size="50"></td>

    </tr>

    <tr>

      <td>Local:</td>

      <td><input name="local" type="text" id="local" size="50"></td>

    </tr>

    <tr>

      <td>Descri&ccedil;&atilde;o:</td>

      <td><textarea name="descricao" cols="44" id="descricao"></textarea></td>

    </tr>

    <tr>

      <td>Quem convida:</td>

      <td><input name="quemconvida" type="text" id="quemconvida" size="50"></td>

    </tr>

    <tr>

      <td>Telefone:</td>

      <td><input name="telefone" type="text" id="telefone" size="50"></td>

    </tr>

    <tr>

      <td>E-mail:</td>

      <td><input name="email" type="text" id="email" size="50"></td>

    </tr>

    <tr>

      <td colspan="2"><div align="center">

    <input type="hidden" name="acao" value="gravar">

    <input type="submit" name="Submit" value="Enviar">

    <input type="reset" name="Submit2" value="Redefinir">

      </div></td>

    </tr>

  </table>

</form>

</body>

</html>

Agora o arquivo que mostra a agenda...

arquivo calendario.php

<? include("config.php");?>

<html>

<head>

  <title>Eventos</title>

<link href="estilo.css" rel="stylesheet" type="text/css">

</head>

<body leftmargin="0" topmargin="0">

<?

if (isset($show_month)) {

if ($show_month==">") {

  if($month==12) {

    $month=1;

    $year++;

    } else {

    $month++;

    }

    }

if ($show_month=="<") {

  if($month==1) {

    $month=12;

    $year--;

    } else {

    $month--;

    }

    }

}

if (isset($day)) {

if ($day<="9"&ereg("(^[1-9]{1})",$day)) {

  $day="0".$day;

  }

}

if (isset($month)) {

if ($month<="9"&ereg("(^[1-9]{1})",$month)) {

  $month="0".$month;

  }

}

if (!isset($year)) {

  $year=date("Y",mktime());

  }

if (!isset($month)) {

  $month=date("m",mktime());

  }

if (!isset($day)) {

  $day=date("d",mktime());

  }

$thisday="$year-$month-$day";

$day_name=array(Seg,Ter,Qua,Qui,Sex,Sáb,"<font color=\"#FF0000\">Dom</font>");

$month_abbr=array("",Janeiro,Fevereiro,Março,Abril,Maio,Junho,Julho,Agosto,Setembro,Outubro,Novembro,Dezembro);

$y=date("Y");

  switch ($month) {

    case 1:  $month_name = Janeiro; break;

    case 2:  $month_name = Fevereiro; break;

    case 3:  $month_name = Março; break;

    case 4:  $month_name = Abril; break;

    case 5:  $month_name = Maio; break;

    case 6:  $month_name = Junho; break;

    case 7:  $month_name = Julho; break;

    case 8:  $month_name = Agosto; break;

    case 9:  $month_name = Setembro; break;

    case 10: $month_name = Outubro; break;

    case 11: $month_name = Novembro; break;

    case 12: $month_name = Dezembro; break;

  }

?>

<table width="176" border="0" cellspacing="0" cellpadding="1">

  <tr align="center">

    <td colspan="7" align="center"><font size="1"><b><? echo "$month_name $year"; ?></b></font></td>

</tr>

<tr  align="center">

  <?

  for ($i=0;$i<7;$i++) { ?>

  <td width="25" align="center"><? echo "$day_name[$i]"; ?></td>

  <? } ?>

</tr>

<tr  align="center">

  <?

  if (date("w",mktime(0,0,0,$month,1,$year))==0) {

    $start=7;

  } else {

    $start=date ("w",mktime(0,0,0,$month,1,$year));

    }

  for($a=($start-2);$a>=0;$a--)

    {

      $d=date("t",mktime(0,0,0,$month,0,$year))-$a;

  ?>

    <td bgcolor="#EEEEEE" align="center" width="25"><?=$d?></td>

  <? }

  for($d=1;$d<=date("t",mktime(0,0,0,($month+1),0,$year));$d++)

        {

    if($month==date("m")&$year==date("Y")&$d==date("d")) {

      $bg="bgcolor=\"#EE9090\"";

} else {

      $bg="bgcolor=\"#CDCDCD\"";

      }

  ?>

<?

$evento = "$d";

$evento.= "$month_name$year.php";

?>

<?

if (file_exists("$path_evento/$evento")) {

?>

    <td bgcolor="orange" align="center" onClick=javaScript:window.open('<? echo "$url_evento/$evento" ?>','','scrollbars=yes,width=350,height=250');history.go(9) style="cursor:hand" width="104"><?=$d?></a></td>

<? } else {?>

    <td <?=$bg?> align="center" width="33"><?=$d?></td>

<? } ?>

  <?

  if(date("w",mktime(0,0,0,$month,$d,$year))==0&date("t",mktime(0,0,0,($month+1),0,$year))>$d)

  {

  ?>

</tr>

<tr align="center">

  <?  }}

  $da=$d+1;

  if(date("w",mktime(0,0,0,$month+1,1,$year))<>1)

        {

          $d=1;

          while(date("w",mktime(0,0,0,($month+1),$d,$year))<>1)

                  {

  ?>

    <td bgcolor="#EEEEEE" align="center" width="25"><?=$d?></td>

  <?

            $d++;

                  }

        }

  ?>

</tr>

</table>

<table width="175" border="0" cellspacing="1" cellpadding="0">

  <tr align="center">

  <td bgcolor="#CDCDCD" align="center" style="border-left: 1px solid rgb(0,0,0); border-right: 1px solid rgb(0,0,0); border-bottom: 1px solid rgb(0,0,0); border-top: 1px solid rgb(0,0,0);">

<? $date = date("d / m / Y"); echo " Hoje: $date "; ?>

</td>

</tr>

<tr align="center">

    <td> Os dias em <font color="orange"><b>laranja</b></font> são dias com compromissos</td>

  </tr>

<tr align="center">

    <td height="2"> </td>

  </tr>

</table>

</body>

</html>

é isso ai..

Eu utilizo umarquivo de estilo.css...

Espero que seja proveitoso

Falou

Adailton

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,7k
×
×
  • Criar Novo...