Jump to content

Faisca78

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Faisca78's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Kalland, Thank you for your help. That did help and the functions.php is now functional. However, I think there's an error in my main php code for the calendar, because when I open the page where it's at, the browser freezes. This is where it can be found: http://illumino.110mb.com This is the code for the calendar: <?php include("functions.php"); $current_time = time(); $day_only_today = date("d",$current_time); if (!$_POST && !isset($_GET["new_months"]) && !isset($_GET["new_year"])){ $months = $_GET['months']; $year = $_GET['year']; }elseif ($_POST) { $months = $_POST["new_months"]; $year = $_POST["new_year"]; }else{ $months = $_GET["new_months"]; $year = $_GET["new_year"]; } if($months == "" || $year == ""){ $year = date("Y"); $months = date("n"); } $last = date("t",mktime(0, 0, 0, $months, 1, $year)); if($months == '12' || $months == '1'){ if($months == '12'){ $next = 1; $prev = $months -1; $nyear = $year + 1; $pyear = $year; } if($months == '1'){ $next = $months + 1; $prev = 12; $nyear = $year; $pyear = $year -1; } }else{ $next = $months + 1; $prev = $months - 1; $pyear = $year; $nyear = $year; } echo "<table width=200 height=10 cellspacing=6 cellpadding=1 border=0> <tr><td colspan=8 align=center class=tit> <table width=100% cellspacing=4 cellpadding=0.5 border=0><tr> <td style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']."?months=$prev&year=$pyear' class=prev></a></td> <td class='title'>$month[$months] $year<td> <td align=right style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']. "?months=$next&year=$nyear' class=next></a></td> </table>"; echo '<tr> <td width=14% align=center class=altn>M</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>O</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>F</td> <td width=14% align=center class=altn>L</td> <td width=14% align=center class=altn>S</td> <td width=18% align=center class=altn>Vecka</td> </tr>'; $cday = "1"; $dayz = loadmatrix($last,$months,$year); $j = 0; while($cday <= $last){ $day = date("D",mktime(0,0,0,$months,$cday,$year)); # returns the day of the week in letters... $date = date("j",mktime(0,0,0,$months,$cday,$year)); #returns the day of the month in 01/31 $day_week = date("w",mktime(0,0,0,$months,$cday,$year)); #retorna el day de la week en numero $event = $year."-".$month_num[$months]."-".$date; if($day == "Mon"){ echo "</tr><tr>"; } if($date == "1"){ $i=1; while($i != $day_week){ echo "<td> </td>"; $i++; } } if($year == date("o") && $month[$months] == $month[date("n")] && $date == date("j")){ if($date == $dayz[$j] ){ echo "<td class='tdday' align='center'><b><a href='index.php?event=$event' target='_self'>$date</a></b></td>"; $j++; }else{ echo "<td class='calendar' align='center'><b>$date</b></td>"; } }else{ if($date == $dayz[$j] ){ echo "<td class='tdday' align='center'><b><a href='index.php?event=$event' target='_self'>$date</a></b></td>"; $j++; }else{ //Sundays if ($day_week == 0){ echo "<td align='center' class='tddom'>$date</td>"; echo "<td align='center' class='week'>".strftime("%V", strtotime("$adate")). "</td>"; }else{ echo "<td align='center'>$date</td>";} } } $cday++; } echo "</tr>"; ?> </table> <div id="date_drop"> <table> <?php function calendarForm($months,$year){ echo ' <table width=200 align="center" cellspacing="1" cellpadding="1" border="0" class=tform> <tr><form action="index.php? '.$_SERVER['PHP_SELF'].' " method="POST">'; echo ' <td align="center" valign="top"> <select name=new_months class="select_month"> <option value="1"'; if ($months==1) echo "selected"; echo'>Januari <option value="2" '; if ($months==2) echo "selected"; echo'>Februari <option value="3" '; if ($months==3) echo "selected"; echo'>Mars <option value="4" '; if ($months==4) echo "selected"; echo '>April <option value="5" '; if ($months==5) echo "selected"; echo '>Maj <option value="6" '; if ($months==6) echo "selected"; echo '>Juni <option value="7" '; if ($months==7) echo "selected"; echo '>Juli <option value="8" '; if ($months== echo "selected"; echo '>Augusti <option value="9" '; if ($months==9) echo "selected"; echo '>September <option value="10" '; if ($months==10) echo "selected"; echo '>Oktober <option value="11" '; if ($months==11) echo "selected"; echo '>November <option value="12" '; if ($months==12) echo "selected"; echo '>December </select> </td>'; echo ' <td align="center" valign="top"> <select name=new_year class="select_yr">'; for ($cont=2006;$cont<$year+3;$cont++){ echo "<option value='$cont'"; if ($year==$cont) echo " selected"; echo ">$cont"; } echo ' </select> </td>'; echo ' <td colspan="1" align="center" valign="top"><input type="Submit" value="GÅ" class="button" /></td> </table> </form>'; } calendarForm($months,$year); ?> </table> <div id="events"> <table> <?php $event = $_GET['event']; if(!isset($event)){ $event = date("Y-m-d"); } $connection = connect(); $sql = "select * from events where date = '$event'"; $res = query($sql); if(mysql_num_rows($res) > 0){ while($line = mysql_fetch_array($res)){ echo "<tr><td class='tddate'>".$line['date']."</td></tr> <tr><td class='tdevent'>".$line['event']."</td></tr>"; } }else{ echo "<tr><td></td></tr>"; } disconnect($connection); ?> Somebody told me at some point that there seemed to be a loop and that's why it froze, but I could not find one. Any ideas on why it gets stuck?? Thanks so much, Nat
  2. Hi everyone, Back in December I posted a topic where I had problems with my calendar. Even though there were some very helpful users, they couldn't do much because it was in Spanish and, therefore, difficult to follow. I have changed it to English in the hope that someone can help me figure out why it's not working. Now I just get an error message when I load it on the website, although back in December all kinds of things were happening, like freezing the browser. Here's the code: <?php include("functions.php"); $current_time = time(); $day_only_today = date("d",$current_time); if (!$_POST && !isset($_GET["new_months"]) && !isset($_GET["new_year"])){ $months = $_GET['months']; $year = $_GET['year']; }elseif ($_POST) { $months = $_POST["new_months"]; $year = $_POST["new_year"]; }else{ $months = $_GET["new_months"]; $year = $_GET["new_year"]; } if($months == "" || $year == ""){ $year = date("Y"); $months = date("n"); } $last = date("t",mktime(0, 0, 0, $months, 1, $year)); if($months == '12' || $months == '1'){ if($months == '12'){ $next = 1; $prev = $months -1; $nyear = $year + 1; $pyear = $year; } if($months == '1'){ $next = $months + 1; $prev = 12; $nyear = $year; $pyear = $year -1; } }else{ $next = $months + 1; $prev = $months - 1; $pyear = $year; $nyear = $year; } echo "<table width=200 height=10 cellspacing=6 cellpadding=1 border=0> <tr><td colspan=8 align=center class=tit> <table width=100% cellspacing=4 cellpadding=0.5 border=0><tr> <td style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']."?months=$prev&year=$pyear' class=prev></a></td> <td class='title'>$month[$months] $year<td> <td align=right style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']. "?months=$next&year=$nyear' class=next></a></td> </table>"; echo '<tr> <td width=14% align=center class=altn>M</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>O</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>F</td> <td width=14% align=center class=altn>L</td> <td width=14% align=center class=altn>S</td> <td width=18% align=center class=altn>Vecka</td> </tr>'; $cday = "1"; $dayz = loadmatrix($last,$months,$year); $j = 0; while($cday <= $last){ $day = date("D",mktime(0,0,0,$months,$cday,$year)); # returns the day of the week in letters... $date = date("j",mktime(0,0,0,$months,$cday,$year)); #returns the day of the month in 01/31 $day_week = date("w",mktime(0,0,0,$months,$cday,$year)); #retorna el day de la week en numero $event = $year."-".$month_num[$months]."-".$date; if($day == "Mon"){ echo "</tr><tr>"; } if($date == "1"){ $i=1; while($i != $day_week){ echo "<td> </td>"; $i++; } } if($year == date("o") && $month[$months] == $month[date("n")] && $date == date("j")){ if($date == $dayz[$j] ){ echo "<td class='tdday' align='center'><b><a href='index.php?event=$event' target='_self'>$date</a></b></td>"; $j++; }else{ echo "<td class='calendar' align='center'><b>$date</b></td>"; } }else{ if($date == $dayz[$j] ){ echo "<td class='tdday' align='center'><b><a href='index.php?event=$event' target='_self'>$date</a></b></td>"; $j++; }else{ //Sundays if ($day_week == 0){ echo "<td align='center' class='tddom'>$date</td>"; echo "<td align='center' class='week'>".strftime("%V", strtotime("$adate")). "</td>"; }else{ echo "<td align='center'>$date</td>";} } } $cday++; } echo "</tr>"; ?> </table> <div id="date_drop"> <table> <?php function calendarForm($months,$year){ echo ' <table width=200 align="center" cellspacing="1" cellpadding="1" border="0" class=tform> <tr><form action="index.php? '.$_SERVER['PHP_SELF'].' " method="POST">'; echo ' <td align="center" valign="top"> <select name=new_months class="select_month"> <option value="1"'; if ($months==1) echo "selected"; echo'>Januari <option value="2" '; if ($months==2) echo "selected"; echo'>Februari <option value="3" '; if ($months==3) echo "selected"; echo'>Mars <option value="4" '; if ($months==4) echo "selected"; echo '>April <option value="5" '; if ($months==5) echo "selected"; echo '>Maj <option value="6" '; if ($months==6) echo "selected"; echo '>Juni <option value="7" '; if ($months==7) echo "selected"; echo '>Juli <option value="8" '; if ($months== echo "selected"; echo '>Augusti <option value="9" '; if ($months==9) echo "selected"; echo '>September <option value="10" '; if ($months==10) echo "selected"; echo '>Oktober <option value="11" '; if ($months==11) echo "selected"; echo '>November <option value="12" '; if ($months==12) echo "selected"; echo '>December </select> </td>'; echo ' <td align="center" valign="top"> <select name=new_year class="select_yr">'; for ($cont=2006;$cont<$year+3;$cont++){ echo "<option value='$cont'"; if ($year==$cont) echo " selected"; echo ">$cont"; } echo ' </select> </td>'; echo ' <td colspan="1" align="center" valign="top"><input type="Submit" value="GÅ" class="button" /></td> </table> </form>'; } calendarForm($months,$year); ?> </table> <div id="events"> <table> <?php $event = $_GET['event']; if(!isset($event)){ $event = date("Y-m-d"); } $connection = connect(); $sql = "select * from events where date = '$event'"; $res = query($sql); if(mysql_num_rows($res) > 0){ while($line = mysql_fetch_array($res)){ echo "<tr><td class='tddate'>".$line['date']."</td></tr> <tr><td class='tdevent'>".$line['event']."</td></tr>"; } }else{ echo "<tr><td></td></tr>"; } disconnect($connection); ?> This is the error message I get: Parse error: syntax error, unexpected T_LOGICAL_OR in /www/110mb.com/i/l/l/u/m/i/n/o/illumino/htdocs/functions.php on line 33 And this is the code for my functions document: <?php $data; $month[1] = "Januari"; $month[2] = "Februari"; $month[3] = "Mars"; $month[4] = "April"; $month[5] = "Maj"; $month[6] = "Juni"; $month[7] = "Juli"; $month[8] = "Augusti"; $month[9] = "September"; $month[10] = "Oktober"; $month[11] = "November"; $month[12] = "December"; $month_num[1] = "01"; $month_num[2] = "02"; $month_num[3] = "03"; $month_num[4] = "04"; $month_num[5] = "05"; $month_num[6] = "06"; $month_num[7] = "07"; $month_num[8] = "08"; $month_num[9] = "09"; $month_num[10] = "10"; $month_num[11] = "11"; $month_num[12] = "12"; $days[0] = "0"; function connect(){ //Put down the data for your localhost connection $host = "localhost"; $userdb = "my_db"; // I put my user db here $pwddb = "pswd"; //I put my password here $db = "db"; //I put the db name here $link = mysql_connect($host,$userdb,$pwddb); or die("It couldn't connect : " . mysql_error()); if (!$link) { die('Not connected : ' . mysql_error()); } $seldb = mysql_select_db($db,$link); if (!$seldb) { die ('Can't use events': ' . mysql_error()); } return $link; } function disconnect($connection){ mysql_close($connection); } function query($sql){ $res = mysql_query($sql) or die (mysql_error()); return $res; } function findevents($last,$months,$year){ $connection = connect(); $from = $year."-".$months."-01"; $to = $year."-".$months."-".$last; $sql = "select * from events where date BETWEEN '$from' and '$to'"; $res = query($sql); if(mysql_num_rows($res) > 1){ echo "<tr><th>DATE</th><th>EVENT</th></tr>"; while($line = mysql_fetch_array($res)){ echo "<tr><td class='tddate'>".$linea['date']."</td><td class='tdevent'>".$line['event']."</td></tr>"; } }else{ echo "<tr><td class='tdno'>There are no events for this month</td></tr>"; } disconnect($connection); } function loadmatrix($last,$months,$year){ $i = 0; $connection = connect(); $from = $year."-".$months."-01"; $to = $year."-".$months."-".$last; // $sql = "select * from events where date BETWEEN '$from' and '$to' order by date"; $sql = "select distinct date from events where date BETWEEN '$from' and '$to' order by date"; $res = query($sql); if(mysql_num_rows($res) > 0){ while($line = mysql_fetch_array($res)){ $date = $line['date']; $day = explode("-", $date); //if($days[$i-1] != $day[2]){ $days[$i] = $days[2]; //} $i++; } }else{ $days[0] = "0"; } disconnect($connection); return $days; } function redirect($time,$url){ print "<meta http-equiv=Refresh content=\"$time ; url=$url\">"; } ?> I would appreciate any help to resolve this issue, as it's been forever and I just want it to work properly. I'm not so good with PHP, so I do need as much help as possible. Thank you so much, Nat
  3. Thanks Corbin, I'll try to find that loop. I would've never guessed that myself;) N.
  4. Thanks everyone! I will try and translate it into English... and you are absolutely right, Spanish and Swedish;) Thanks so much for the help, N.
  5. Hi, I posted a topic a few weeks ago because I have problems with my calendar script. I still haven't been able to solve it, so I was hoping somebody with more experience could help me out. These are the problems I'm experiencing: 1. - The calendar "freezes" in the browser after going through a few months in the past or in the future. I don't know why and/or it has to do with the events. 2.- When I look at an event, in any month, the calendar goes back to the current month while showing me the event, which gets very confusing. 3.- The week numbers (i.e. 1-52) do not show properly... at the moment, all the weeks are numbered 01, and I don't really understand why. Besides, when a week is not full (i.e. the last day of the month doesn't fall on a Sunday) the week number doesn't show. 4.- The months in the drop down months menu change along with the months in the top menu. I wonder if they can remain in the current month. This is not important, and it doesn't matter too much. This is my calendar's code: <table border=0 cellspacing=0> <?php include("functions.php"); $tiempo_actual = time(); $dia_solo_hoy = date("d",$tiempo_actual); if (!$_POST && !isset($_GET["nuevo_mess"]) && !isset($_GET["nuevo_anio"])){ $mess = $_GET['mess']; $anio = $_GET['anio']; }elseif ($_POST) { $mess = $_POST["nuevo_mess"]; $anio = $_POST["nuevo_anio"]; }else{ $mess = $_GET["nuevo_mess"]; $anio = $_GET["nuevo_anio"]; } if($mess == "" || $anio == ""){ $anio = date("Y"); $mess = date("n"); } $ultimo = date("t",mktime(0, 0, 0, $mess, 1, $anio)); if($mess == '12' || $mess == '1'){ if($mess == '12'){ $next = 1; $prev = $mess -1; $anion = $anio + 1; $aniop = $anio; } if($mess == '1'){ $next = $mess + 1; $prev = 12; $anion = $anio; $aniop = $anio -1; } }else{ $next = $mess + 1; $prev = $mess - 1; $aniop = $anio; $anion = $anio; } echo "<table width=200 height=10 cellspacing=6 cellpadding=0.5 border=0> <tr> <td colspan=8 align=center class=tit> <table width=100% cellspacing=4 cellpadding=0.5 border=0><tr> <td style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']."?mess=$prev&anio=$aniop' class=prev> </a></td> <td class='title'>$mes[$mess] $anio<td> <td align=right style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']. "?mess=$next&anio=$anion' class=next> </a></td> </table>"; echo '<tr> <td width=14% align=center class=altn>M</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>O</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>F</td> <td width=14% align=center class=altn>L</td> <td width=14% align=center class=altn>S</td> <td width=18% align=center class=altn>Vecka</td> </tr>'; $diaa = "1"; $diaz = cargarmatriz($ultimo,$mess,$anio); $j = 0; while($diaa <= $ultimo){ $dia = date("D",mktime(0,0,0,$mess,$diaa,$anio)); # return week days in letters $fecha = date("j",mktime(0,0,0,$mess,$diaa,$anio)); #returns the day of the month in 01/31 $dia_semana = date("w",mktime(0,0,0,$mess,$diaa,$anio)); #returns the day of the week in numbers $evento = $anio."-".$mes_num[$mess]."-".$fecha; if($dia == "Mon"){ echo "</tr><tr>"; } if($fecha == "1"){ $i=1; while($i != $dia_semana){ echo "<td> </td>"; $i++; } } if($anio == date("o") && $mes[$mess] == $mes[date("n")] && $fecha == date("j")){ if($fecha == $diaz[$j] ){ echo "<td class='tddia' align='center'><b><a href='index.php?evento=$evento' target='_self'>$fecha</a> </b></td>"; $j++; }else{ echo "<td class='calendario' align='center'><b>$fecha</b></td>"; } }else{ if($fecha == $diaz[$j] ){ echo "<td class='tddia' align='center'><b><a href='index.php?evento=$evento' target='_self'>$fecha</a> </b></td>"; $j++; }else{ //Sundays if ($dia_semana == 0){ echo "<td align='center' class='tddom'>$fecha</td>"; echo "<td align='center' class='week'>".strftime("%V", strtotime("$adate")). "</td>"; # returns week in the year in numbers }else{ echo "<td align='center'>$fecha</td>";} } } $diaa++; } echo "</tr>"; ?> </table> <div id="fecha_drop"> <table> <?php function formularioCalendario($mess,$anio){ echo ' <table width=200 align="center" cellspacing="1" cellpadding="1" border="0" class=tform> <tr><form action="index.php? '.$_SERVER['PHP_SELF'].' " method="POST">'; echo ' <td align="center" valign="top"> <select name=nuevo_mess class="select_month"> <option value="1"'; if ($mess==1) echo "selected"; echo'>Januari <option value="2" '; if ($mess==2) echo "selected"; echo'>Februari <option value="3" '; if ($mess==3) echo "selected"; echo'>Mars <option value="4" '; if ($mess==4) echo "selected"; echo '>April <option value="5" '; if ($mess==5) echo "selected"; echo '>Maj <option value="6" '; if ($mess==6) echo "selected"; echo '>Juni <option value="7" '; if ($mess==7) echo "selected"; echo '>Juli <option value="8" '; if ($mess== echo "selected"; echo '>Augusti <option value="9" '; if ($mess==9) echo "selected"; echo '>September <option value="10" '; if ($mess==10) echo "selected"; echo '>Oktober <option value="11" '; if ($mess==11) echo "selected"; echo '>November <option value="12" '; if ($mess==12) echo "selected"; echo '>December </select> </td>'; echo ' <td align="center" valign="top"> <select name=nuevo_anio class="select_yr">'; for ($cont=2006;$cont<$anio+3;$cont++){ echo "<option value='$cont'"; if ($anio==$cont) echo " selected"; echo ">$cont"; } echo ' </select> </td>'; echo ' <td colspan="1" align="center" valign="top"><input type="Submit" value="GÅ" class="button" /></td> </table> </form>'; } formularioCalendario($mess,$anio); ?> </table> <div id="events"> <table> <?php $evento = $_GET['evento']; if(!isset($evento)){ $evento = date("Y-m-d"); } $conexion = conectar(); $sql = "select * from eventos where fecha = '$evento'"; $res = query($sql); if(mysql_num_rows($res) > 0){ while($fila = mysql_fetch_array($res)){ echo "<tr><td class='tdfecha'>".$fila['fecha']."</td></tr> <tr><td class='tdevento'>".$fila['evento']."</td></tr>"; } }else{ echo "<tr><td></td></tr>"; } desconectar($conexion); ?> </table> And this is the website where the calendar can be previewed: illumino.110mb.com Following is the code for the functions.php file: <?php $datos; $mes[1] = "Januari"; $mes[2] = "Februari"; $mes[3] = "Mars"; $mes[4] = "April"; $mes[5] = "Maj"; $mes[6] = "Juni"; $mes[7] = "Juli"; $mes[8] = "Augusti"; $mes[9] = "September"; $mes[10] = "Oktober"; $mes[11] = "November"; $mes[12] = "December"; $mes_num[1] = "01"; $mes_num[2] = "02"; $mes_num[3] = "03"; $mes_num[4] = "04"; $mes_num[5] = "05"; $mes_num[6] = "06"; $mes_num[7] = "07"; $mes_num[8] = "08"; $mes_num[9] = "09"; $mes_num[10] = "10"; $mes_num[11] = "11"; $mes_num[12] = "12"; $dias[0] = "0"; function conectar(){ //Put the data for your localhost $host = "localhost"; $usuariodb = "*******"; $pwddb = "*******"; $db = "*******"; $enlace = mysql_connect($host,$usuariodb,$pwddb);// or die("It couldn't connect : " . mysql_error()); if (!$enlace) { die('Not connected : ' . mysql_error()); } $seldb = mysql_select_db($db,$enlace); if (!$seldb) { die ('No se puede usar eventos: ' . mysql_error()); } return $enlace; } function desconectar($conexion){ mysql_close($conexion); } function query($sql){ $res = mysql_query($sql) or die (mysql_error()); return $res; } function buscareventos($ultimo,$mess,$anio){ $conexion = conectar(); $desde = $anio."-".$mess."-01"; $hasta = $anio."-".$mess."-".$ultimo; $sql = "select * from eventos where fecha BETWEEN '$desde' and '$hasta'"; $res = query($sql); if(mysql_num_rows($res) > 1){ echo "<tr><th>FECHA</th><th>EVENTO</th></tr>"; while($fila = mysql_fetch_array($res)){ echo "<tr><td class='tdfecha'>".$fila['fecha']."</td><td class='tdevento'>".$fila['evento']."</td></tr>"; } }else{ echo "<tr><td class='tdno'>There are no events this month</td> </tr>"; } desconectar($conexion); } function cargarmatriz($ultimo,$mess,$anio){ $i = 0; $conexion = conectar(); $desde = $anio."-".$mess."-01"; $hasta = $anio."-".$mess."-".$ultimo; // $sql = "select * from eventos where fecha BETWEEN '$desde' and '$hasta' order by fecha"; $sql = "select distinct fecha from eventos where fecha BETWEEN '$desde' and '$hasta' order by fecha"; $res = query($sql); if(mysql_num_rows($res) > 0){ while($fila = mysql_fetch_array($res)){ $fecha = $fila['fecha]; $dia = explode("-", $fecha); //if($dias[$i-1] != $dia[2]){ $dias[$i] = $dia[2]; //} $i++; } }else{ $dias[0] = "0"; } desconectar($conexion); return $dias; } function redireccionar($time,$url){ print "<meta http-equiv=Refresh content=\"$time ; url=$url\">"; } ?> Thanks a lot for any help, N.
  6. Let me try again with the tabs and the code. I re-enter my problems and thanks again for the help:) The time before would've been good, except my browser crashed before I was able to enter the code properly. My bad and sorry for the duplicates I've got a problem with my calendar. I'm not very good with PHP, therefore I need lots of help with this. I've got a calendar with events and weeks. Mi problems are as follow: 1. - The calendar "freezes" in the browser after going through a few months in the past or in the future. I don't know why and/or it has to do with the events. 2.- When I look at an event, in any month, the calendar goes back to the current month while showing me the event, which gets very confusing. 3.- The week numbers (i.e. 1-52) do not show properly... at the moment, all the weeks are numbered 01, and I don't really understand why. Besides, when a week is not full (i.e. the last day of the month doesn't fall on a Sunday) the week number doesn't show. 4.- The months in the drop down months menu change along with the months in the top menu. I wonder if they can remain in the current month. This is not important, and it doesn't matter too much. This is my calendar's code: <table border=0 cellspacing=0> <?php include("functions.php"); $tiempo_actual = time(); $dia_solo_hoy = date("d",$tiempo_actual); if (!$_POST && !isset($_GET["nuevo_mess"]) && !isset($_GET["nuevo_anio"])){ $mess = $_GET['mess']; $anio = $_GET['anio']; }elseif ($_POST) { $mess = $_POST["nuevo_mess"]; $anio = $_POST["nuevo_anio"]; }else{ $mess = $_GET["nuevo_mess"]; $anio = $_GET["nuevo_anio"]; } if($mess == "" || $anio == ""){ $anio = date("Y"); $mess = date("n"); } $ultimo = date("t",mktime(0, 0, 0, $mess, 1, $anio)); if($mess == '12' || $mess == '1'){ if($mess == '12'){ $next = 1; $prev = $mess -1; $anion = $anio + 1; $aniop = $anio; } if($mess == '1'){ $next = $mess + 1; $prev = 12; $anion = $anio; $aniop = $anio -1; } }else{ $next = $mess + 1; $prev = $mess - 1; $aniop = $anio; $anion = $anio; } echo "<table width=200 height=10 cellspacing=6 cellpadding=0.5 border=0> <tr> <td colspan=8 align=center class=tit> <table width=100% cellspacing=4 cellpadding=0.5 border=0><tr> <td style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']."?mess=$prev&anio=$aniop' class=prev> </a></td> <td class='title'>$mes[$mess] $anio<td> <td align=right style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']. "?mess=$next&anio=$anion' class=next> </a></td> </table>"; echo '<tr> <td width=14% align=center class=altn>M</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>O</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>F</td> <td width=14% align=center class=altn>L</td> <td width=14% align=center class=altn>S</td> <td width=18% align=center class=altn>Vecka</td> </tr>'; $diaa = "1"; $diaz = cargarmatriz($ultimo,$mess,$anio); $j = 0; while($diaa <= $ultimo){ $dia = date("D",mktime(0,0,0,$mess,$diaa,$anio)); # return week days in letters $fecha = date("j",mktime(0,0,0,$mess,$diaa,$anio)); #returns the day of the month in 01/31 $dia_semana = date("w",mktime(0,0,0,$mess,$diaa,$anio)); #returns the day of the week in numbers $evento = $anio."-".$mes_num[$mess]."-".$fecha; if($dia == "Mon"){ echo "</tr><tr>"; } if($fecha == "1"){ $i=1; while($i != $dia_semana){ echo "<td> </td>"; $i++; } } if($anio == date("o") && $mes[$mess] == $mes[date("n")] && $fecha == date("j")){ if($fecha == $diaz[$j] ){ echo "<td class='tddia' align='center'><b><a href='index.php?evento=$evento' target='_self'>$fecha</a> </b></td>"; $j++; }else{ echo "<td class='calendario' align='center'><b>$fecha</b></td>"; } }else{ if($fecha == $diaz[$j] ){ echo "<td class='tddia' align='center'><b><a href='index.php?evento=$evento' target='_self'>$fecha</a> </b></td>"; $j++; }else{ //Sundays if ($dia_semana == 0){ echo "<td align='center' class='tddom'>$fecha</td>"; echo "<td align='center' class='week'>".strftime("%V", strtotime("$adate")). "</td>"; # returns week in the year in numbers }else{ echo "<td align='center'>$fecha</td>";} } } $diaa++; } echo "</tr>"; ?> </table> <div id="fecha_drop"> <table> <?php function formularioCalendario($mess,$anio){ echo ' <table width=200 align="center" cellspacing="1" cellpadding="1" border="0" class=tform> <tr><form action="index.php? '.$_SERVER['PHP_SELF'].' " method="POST">'; echo ' <td align="center" valign="top"> <select name=nuevo_mess class="select_month"> <option value="1"'; if ($mess==1) echo "selected"; echo'>Januari <option value="2" '; if ($mess==2) echo "selected"; echo'>Februari <option value="3" '; if ($mess==3) echo "selected"; echo'>Mars <option value="4" '; if ($mess==4) echo "selected"; echo '>April <option value="5" '; if ($mess==5) echo "selected"; echo '>Maj <option value="6" '; if ($mess==6) echo "selected"; echo '>Juni <option value="7" '; if ($mess==7) echo "selected"; echo '>Juli <option value="8" '; if ($mess== echo "selected"; echo '>Augusti <option value="9" '; if ($mess==9) echo "selected"; echo '>September <option value="10" '; if ($mess==10) echo "selected"; echo '>Oktober <option value="11" '; if ($mess==11) echo "selected"; echo '>November <option value="12" '; if ($mess==12) echo "selected"; echo '>December </select> </td>'; echo ' <td align="center" valign="top"> <select name=nuevo_anio class="select_yr">'; for ($cont=2006;$cont<$anio+3;$cont++){ echo "<option value='$cont'"; if ($anio==$cont) echo " selected"; echo ">$cont"; } echo ' </select> </td>'; echo ' <td colspan="1" align="center" valign="top"><input type="Submit" value="GÅ" class="button" /></td> </table> </form>'; } formularioCalendario($mess,$anio); ?> </table> <div id="events"> <table> <?php $evento = $_GET['evento']; if(!isset($evento)){ $evento = date("Y-m-d"); } $conexion = conectar(); $sql = "select * from eventos where fecha = '$evento'"; $res = query($sql); if(mysql_num_rows($res) > 0){ while($fila = mysql_fetch_array($res)){ echo "<tr><td class='tdfecha'>".$fila['fecha']."</td></tr> <tr><td class='tdevento'>".$fila['evento']."</td></tr>"; } }else{ echo "<tr><td></td></tr>"; } desconectar($conexion); ?> </table> And this is the website where the calendar can be previewed: illumino.110mb.com Following is the code for the functions.php file: <?php $datos; $mes[1] = "Januari"; $mes[2] = "Februari"; $mes[3] = "Mars"; $mes[4] = "April"; $mes[5] = "Maj"; $mes[6] = "Juni"; $mes[7] = "Juli"; $mes[8] = "Augusti"; $mes[9] = "September"; $mes[10] = "Oktober"; $mes[11] = "November"; $mes[12] = "December"; $mes_num[1] = "01"; $mes_num[2] = "02"; $mes_num[3] = "03"; $mes_num[4] = "04"; $mes_num[5] = "05"; $mes_num[6] = "06"; $mes_num[7] = "07"; $mes_num[8] = "08"; $mes_num[9] = "09"; $mes_num[10] = "10"; $mes_num[11] = "11"; $mes_num[12] = "12"; $dias[0] = "0"; function conectar(){ //Put the data for your localhost $host = "localhost"; $usuariodb = "*******"; $pwddb = "*******"; $db = "*******"; $enlace = mysql_connect($host,$usuariodb,$pwddb);// or die("It couldn't connect : " . mysql_error()); if (!$enlace) { die('Not connected : ' . mysql_error()); } $seldb = mysql_select_db($db,$enlace); if (!$seldb) { die ('No se puede usar eventos: ' . mysql_error()); } return $enlace; } function desconectar($conexion){ mysql_close($conexion); } function query($sql){ $res = mysql_query($sql) or die (mysql_error()); return $res; } function buscareventos($ultimo,$mess,$anio){ $conexion = conectar(); $desde = $anio."-".$mess."-01"; $hasta = $anio."-".$mess."-".$ultimo; $sql = "select * from eventos where fecha BETWEEN '$desde' and '$hasta'"; $res = query($sql); if(mysql_num_rows($res) > 1){ echo "<tr><th>FECHA</th><th>EVENTO</th></tr>"; while($fila = mysql_fetch_array($res)){ echo "<tr><td class='tdfecha'>".$fila['fecha']."</td><td class='tdevento'>".$fila['evento']."</td></tr>"; } }else{ echo "<tr><td class='tdno'>There are no events this month</td> </tr>"; } desconectar($conexion); } function cargarmatriz($ultimo,$mess,$anio){ $i = 0; $conexion = conectar(); $desde = $anio."-".$mess."-01"; $hasta = $anio."-".$mess."-".$ultimo; // $sql = "select * from eventos where fecha BETWEEN '$desde' and '$hasta' order by fecha"; $sql = "select distinct fecha from eventos where fecha BETWEEN '$desde' and '$hasta' order by fecha"; $res = query($sql); if(mysql_num_rows($res) > 0){ while($fila = mysql_fetch_array($res)){ $fecha = $fila['fecha]; $dia = explode("-", $fecha); //if($dias[$i-1] != $dia[2]){ $dias[$i] = $dia[2]; //} $i++; } }else{ $dias[0] = "0"; } desconectar($conexion); return $dias; } function redireccionar($time,$url){ print "<meta http-equiv=Refresh content=\"$time ; url=$url\">"; } ?> Thanks a lot for any help, N.
  7. Let me try again with the tabs and the code. I re-enter my problems and thanks again for the help:) I've got a problem with my calendar. I'm not very good with PHP, therefore I need lots of help with this. I've got a calendar with events and weeks. Mi problems are as follow: 1. - The calendar "freezes" in the browser after going through a few months in the past or in the future. I don't know why and/or it has to do with the events. 2.- When I look at an event, in any month, the calendar goes back to the current month while showing me the event, which gets very confusing. 3.- The week numbers (i.e. 1-52) do not show properly... at the moment, all the weeks are numbered 01, and I don't really understand why. Besides, when a week is not full (i.e. the last day of the month doesn't fall on a Sunday) the week number doesn't show. 4.- The months in the drop down months menu change along with the months in the top menu. I wonder if they can remain in the current month. This is not important, and it doesn't matter too much. This is my calendar's code: <table border=0 cellspacing=0> <?php include("functions.php"); $tiempo_actual = time(); $dia_solo_hoy = date("d",$tiempo_actual); if (!$_POST && !isset($_GET["nuevo_mess"]) && !isset($_GET["nuevo_anio"])){ $mess = $_GET['mess']; $anio = $_GET['anio']; }elseif ($_POST) { $mess = $_POST["nuevo_mess"]; $anio = $_POST["nuevo_anio"]; }else{ $mess = $_GET["nuevo_mess"]; $anio = $_GET["nuevo_anio"]; } if($mess == "" || $anio == ""){ $anio = date("Y"); $mess = date("n"); } $ultimo = date("t",mktime(0, 0, 0, $mess, 1, $anio)); if($mess == '12' || $mess == '1'){ if($mess == '12'){ $next = 1; $prev = $mess -1; $anion = $anio + 1; $aniop = $anio; } if($mess == '1'){ $next = $mess + 1; $prev = 12; $anion = $anio; $aniop = $anio -1; } }else{ $next = $mess + 1; $prev = $mess - 1; $aniop = $anio; $anion = $anio; } echo "<table width=200 height=10 cellspacing=6 cellpadding=0.5 border=0> <tr> <td colspan=8 align=center class=tit> <table width=100% cellspacing=4 cellpadding=0.5 border=0><tr> <td style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']."?mess=$prev&anio=$aniop' class=prev> </a></td> <td class='title'>$mes[$mess] $anio<td> <td align=right style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']. "?mess=$next&anio=$anion' class=next> </a></td> </table>"; echo '<tr> <td width=14% align=center class=altn>M</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>O</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>F</td> <td width=14% align=center class=altn>L</td> <td width=14% align=center class=altn>S</td> <td width=18% align=center class=altn>Vecka</td> </tr>'; $diaa = "1"; $diaz = cargarmatriz($ultimo,$mess,$anio); $j = 0; while($diaa <= $ultimo){ $dia = date("D",mktime(0,0,0,$mess,$diaa,$anio)); # return week days in letters $fecha = date("j",mktime(0,0,0,$mess,$diaa,$anio)); #returns the day of the month in 01/31 $dia_semana = date("w",mktime(0,0,0,$mess,$diaa,$anio)); #returns the day of the week in numbers $evento = $anio."-".$mes_num[$mess]."-".$fecha; if($dia == "Mon"){ echo "</tr><tr>"; } if($fecha == "1"){ $i=1; while($i != $dia_semana){ echo "<td> </td>"; $i++; } } if($anio == date("o") && $mes[$mess] == $mes[date("n")] && $fecha == date("j")){ if($fecha == $diaz[$j] ){ echo "<td class='tddia' align='center'><b><a href='index.php?evento=$evento' target='_self'>$fecha</a> </b></td>"; $j++; }else{ echo "<td class='calendario' align='center'><b>$fecha</b></td>"; } }else{ if($fecha == $diaz[$j] ){ echo "<td class='tddia' align='center'><b><a href='index.php?evento=$evento' target='_self'>$fecha</a> </b></td>"; $j++; }else{ //Sundays if ($dia_semana == 0){ echo "<td align='center' class='tddom'>$fecha</td>"; echo "<td align='center' class='week'>".strftime("%V", strtotime("$adate")). "</td>"; # returns week in the year in numbers }else{ echo "<td align='center'>$fecha</td>";} } } $diaa++; } echo "</tr>"; ?> </table> <div id="fecha_drop"> <table> <? function formularioCalendario($mess,$anio){ echo ' <table width=200 align="center" cellspacing="1" cellpadding="1" border="0" class=tform> <tr><form action="index.php? '.$_SERVER['PHP_SELF'].' " method="POST">'; echo ' <td align="center" valign="top"> <select name=nuevo_mess class="select_month"> <option value="1"'; if ($mess==1) echo "selected"; echo'>Januari <option value="2" '; if ($mess==2) echo "selected"; echo'>Februari <option value="3" '; if ($mess==3) echo "selected"; echo'>Mars <option value="4" '; if ($mess==4) echo "selected"; echo '>April <option value="5" '; if ($mess==5) echo "selected"; echo '>Maj <option value="6" '; if ($mess==6) echo "selected"; echo '>Juni <option value="7" '; if ($mess==7) echo "selected"; echo '>Juli <option value="8" '; if ($mess== echo "selected"; echo '>Augusti <option value="9" '; if ($mess==9) echo "selected"; echo '>September <option value="10" '; if ($mess==10) echo "selected"; echo '>Oktober <option value="11" '; if ($mess==11) echo "selected"; echo '>November <option value="12" '; if ($mess==12) echo "selected"; echo '>December </select> </td>'; echo ' <td align="center" valign="top"> <select name=nuevo_anio class="select_yr">'; for ($cont=2006;$cont<$anio+3;$cont++){ echo "<option value='$cont'"; if ($anio==$cont) echo " selected"; echo ">$cont"; } echo ' </select> </td>'; echo ' <td colspan="1" align="center" valign="top"><input type="Submit" value="GÅ" class="button" /></td> </table> </form>'; } formularioCalendario($mess,$anio); ?> </table> <div id="events"> <table> <? $evento = $_GET['evento']; if(!isset($evento)){ $evento = date("Y-m-d"); } $conexion = conectar(); $sql = "select * from eventos where fecha = '$evento'"; $res = query($sql); if(mysql_num_rows($res) > 0){ while($fila = mysql_fetch_array($res)){ echo "<tr><td class='tdfecha'>".$fila['fecha']."</td></tr> <tr><td class='tdevento'>".$fila['evento']."</td></tr>"; } }else{ echo "<tr><td></td></tr>"; } desconectar($conexion); ?> </table> And this is the website where the calendar can be previewed: illumino.110mb.com Following is the code for the functions.php file: <?php $datos; $mes[1] = "Januari"; $mes[2] = "Februari"; $mes[3] = "Mars"; $mes[4] = "April"; $mes[5] = "Maj"; $mes[6] = "Juni"; $mes[7] = "Juli"; $mes[8] = "Augusti"; $mes[9] = "September"; $mes[10] = "Oktober"; $mes[11] = "November"; $mes[12] = "December"; $mes_num[1] = "01"; $mes_num[2] = "02"; $mes_num[3] = "03"; $mes_num[4] = "04"; $mes_num[5] = "05"; $mes_num[6] = "06"; $mes_num[7] = "07"; $mes_num[8] = "08"; $mes_num[9] = "09"; $mes_num[10] = "10"; $mes_num[11] = "11"; $mes_num[12] = "12"; $dias[0] = "0"; function conectar(){ //Put the data for your localhost $host = "localhost"; $usuariodb = "*******"; $pwddb = "*******"; $db = "*******"; $enlace = mysql_connect($host,$usuariodb,$pwddb);// or die("It couldn't connect : " . mysql_error()); if (!$enlace) { die('Not connected : ' . mysql_error()); } $seldb = mysql_select_db($db,$enlace); if (!$seldb) { die ('No se puede usar eventos: ' . mysql_error()); } return $enlace; } function desconectar($conexion){ mysql_close($conexion); } function query($sql){ $res = mysql_query($sql) or die (mysql_error()); return $res; } function buscareventos($ultimo,$mess,$anio){ $conexion = conectar(); $desde = $anio."-".$mess."-01"; $hasta = $anio."-".$mess."-".$ultimo; $sql = "select * from eventos where fecha BETWEEN '$desde' and '$hasta'"; $res = query($sql); if(mysql_num_rows($res) > 1){ echo "<tr><th>FECHA</th><th>EVENTO</th></tr>"; while($fila = mysql_fetch_array($res)){ echo "<tr><td class='tdfecha'>".$fila['fecha']."</td><td class='tdevento'>".$fila['evento']."</td></tr>"; } }else{ echo "<tr><td class='tdno'>There are no events this month</td> </tr>"; } desconectar($conexion); } function cargarmatriz($ultimo,$mess,$anio){ $i = 0; $conexion = conectar(); $desde = $anio."-".$mess."-01"; $hasta = $anio."-".$mess."-".$ultimo; // $sql = "select * from eventos where fecha BETWEEN '$desde' and '$hasta' order by fecha"; $sql = "select distinct fecha from eventos where fecha BETWEEN '$desde' and '$hasta' order by fecha"; $res = query($sql); if(mysql_num_rows($res) > 0){ while($fila = mysql_fetch_array($res)){ $fecha = $fila['fecha']; $dia = explode("-", $fecha); //if($dias[$i-1] != $dia[2]){ $dias[$i] = $dia[2]; //} $i++; } }else{ $dias[0] = "0"; } desconectar($conexion); return $dias; } function redireccionar($time,$url){ print "<meta http-equiv=Refresh content=\"$time ; url=$url\">"; } ?> Thanks a lot for any help, N.
  8. Thanks for clearing that out, Chronister. I will do that and hopefully it will help to visualize it so I can get the help... I'm not a programmer, so I get confused with all this.
  9. Hey, Thanks for your reply... but, imagine you are dealing with a 3 year-old... hehehe... what do you mean by code tags?
  10. Hi every1, I've got a problem with my calendar. I'm not very good with PHP, therefore I need lots of help with this. I've got a calendar with events and weeks. Mi problems are as follow: 1. - The calendar "freezes" in the browser after going through a few months in the past or in the future. I don't know why and/or it has to do with the events. 2.- When I look at an event, in any month, the calendar goes back to the current month while showing me the event, which gets very confusing. 3.- The week numbers (i.e. 1-52) do not show properly... at the moment, all the weeks are numbered 01, and I don't really understand why. Besides, when a week is not full (i.e. the last day of the month doesn't fall on a Sunday) the week number doesn't show. 4.- The months in the drop down months menu change along with the months in the top menu. I wonder if they can remain in the current month. This is not important, and it doesn't matter too much. This is my calendar's code: <table border=0 cellspacing=0> <?php include("functions.php"); $tiempo_actual = time(); $dia_solo_hoy = date("d",$tiempo_actual); if (!$_POST && !isset($_GET["nuevo_mess"]) && !isset($_GET["nuevo_anio"])){ $mess = $_GET['mess']; $anio = $_GET['anio']; }elseif ($_POST) { $mess = $_POST["nuevo_mess"]; $anio = $_POST["nuevo_anio"]; }else{ $mess = $_GET["nuevo_mess"]; $anio = $_GET["nuevo_anio"]; } if($mess == "" || $anio == ""){ $anio = date("Y"); $mess = date("n"); } $ultimo = date("t",mktime(0, 0, 0, $mess, 1, $anio)); if($mess == '12' || $mess == '1'){ if($mess == '12'){ $next = 1; $prev = $mess -1; $anion = $anio + 1; $aniop = $anio; } if($mess == '1'){ $next = $mess + 1; $prev = 12; $anion = $anio; $aniop = $anio -1; } }else{ $next = $mess + 1; $prev = $mess - 1; $aniop = $anio; $anion = $anio; } echo "<table width=200 height=10 cellspacing=6 cellpadding=0.5 border=0> <tr> <td colspan=8 align=center class=tit> <table width=100% cellspacing=4 cellpadding=0.5 border=0><tr> <td style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']."?mess=$prev&anio=$aniop' class=prev></a></td> <td class='title'>$mes[$mess] $anio<td> <td align=right style=font-size:10pt;font-weight:bold;color:white><a href='".$_SERVER['PHP_SELF']. "?mess=$next&anio=$anion' class=next></a></td> </table>"; echo '<tr> <td width=14% align=center class=altn>M</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>O</td> <td width=14% align=center class=altn>T</td> <td width=14% align=center class=altn>F</td> <td width=14% align=center class=altn>L</td> <td width=14% align=center class=altn>S</td> <td width=18% align=center class=altn>Vecka</td> </tr>'; $diaa = "1"; $diaz = cargarmatriz($ultimo,$mess,$anio); $j = 0; while($diaa <= $ultimo){ $dia = date("D",mktime(0,0,0,$mess,$diaa,$anio)); # retorna el dia de la semana en letras... $fecha = date("j",mktime(0,0,0,$mess,$diaa,$anio)); #retorna el dia del mes en 01/31 $dia_semana = date("w",mktime(0,0,0,$mess,$diaa,$anio)); #retorna el dia de la semana en numero $evento = $anio."-".$mes_num[$mess]."-".$fecha; if($dia == "Mon"){ echo "</tr><tr>"; } if($fecha == "1"){ $i=1; while($i != $dia_semana){ echo "<td> </td>"; $i++; } } if($anio == date("o") && $mes[$mess] == $mes[date("n")] && $fecha == date("j")){ if($fecha == $diaz[$j] ){ echo "<td class='tddia' align='center'><b><a href='index.php?evento=$evento' target='_self'>$fecha</a></b></td>"; $j++; }else{ echo "<td class='calendario' align='center'><b>$fecha</b></td>"; } }else{ if($fecha == $diaz[$j] ){ echo "<td class='tddia' align='center'><b><a href='index.php?evento=$evento' target='_self'>$fecha</a></b></td>"; $j++; }else{ //Domingos if ($dia_semana == 0){ echo "<td align='center' class='tddom'>$fecha</td>"; echo "<td align='center' class='week'>".strftime("%V", strtotime("$adate")). "</td>"; }else{ echo "<td align='center'>$fecha</td>";} } } $diaa++; } echo "</tr>"; ?> </table> <div id="fecha_drop"> <table> <? function formularioCalendario($mess,$anio){ echo ' <table width=200 align="center" cellspacing="1" cellpadding="1" border="0" class=tform> <tr><form action="index.php? '.$_SERVER['PHP_SELF'].' " method="POST">'; echo ' <td align="center" valign="top"> <select name=nuevo_mess class="select_month"> <option value="1"'; if ($mess==1) echo "selected"; echo'>Januari <option value="2" '; if ($mess==2) echo "selected"; echo'>Februari <option value="3" '; if ($mess==3) echo "selected"; echo'>Mars <option value="4" '; if ($mess==4) echo "selected"; echo '>April <option value="5" '; if ($mess==5) echo "selected"; echo '>Maj <option value="6" '; if ($mess==6) echo "selected"; echo '>Juni <option value="7" '; if ($mess==7) echo "selected"; echo '>Juli <option value="8" '; if ($mess== echo "selected"; echo '>Augusti <option value="9" '; if ($mess==9) echo "selected"; echo '>September <option value="10" '; if ($mess==10) echo "selected"; echo '>Oktober <option value="11" '; if ($mess==11) echo "selected"; echo '>November <option value="12" '; if ($mess==12) echo "selected"; echo '>December </select> </td>'; echo ' <td align="center" valign="top"> <select name=nuevo_anio class="select_yr">'; for ($cont=2006;$cont<$anio+3;$cont++){ echo "<option value='$cont'"; if ($anio==$cont) echo " selected"; echo ">$cont"; } echo ' </select> </td>'; echo ' <td colspan="1" align="center" valign="top"><input type="Submit" value="GÅ" class="button" /></td> </table> </form>'; } formularioCalendario($mess,$anio); ?> </table> <div id="events"> <table> <? $evento = $_GET['evento']; if(!isset($evento)){ $evento = date("Y-m-d"); } $conexion = conectar(); $sql = "select * from eventos where fecha = '$evento'"; $res = query($sql); if(mysql_num_rows($res) > 0){ while($fila = mysql_fetch_array($res)){ echo "<tr><td class='tdfecha'>".$fila['fecha']."</td></tr> <tr><td class='tdevento'>".$fila['evento']."</td></tr>"; } }else{ echo "<tr><td></td></tr>"; } desconectar($conexion); ?> </table> And this is the website where the calendar can be previewed: illumino.110mb.com Following is the code for the functions.php file: <?php $datos; $mes[1] = "Januari"; $mes[2] = "Februari"; $mes[3] = "Mars"; $mes[4] = "April"; $mes[5] = "Maj"; $mes[6] = "Juni"; $mes[7] = "Juli"; $mes[8] = "Augusti"; $mes[9] = "September"; $mes[10] = "Oktober"; $mes[11] = "November"; $mes[12] = "December"; $mes_num[1] = "01"; $mes_num[2] = "02"; $mes_num[3] = "03"; $mes_num[4] = "04"; $mes_num[5] = "05"; $mes_num[6] = "06"; $mes_num[7] = "07"; $mes_num[8] = "08"; $mes_num[9] = "09"; $mes_num[10] = "10"; $mes_num[11] = "11"; $mes_num[12] = "12"; $dias[0] = "0"; function conectar(){ //Pon los datos de conexión de tu localhost $host = "localhost"; $usuariodb = "*******"; $pwddb = "*******"; $db = "*******"; $enlace = mysql_connect($host,$usuariodb,$pwddb);// or die("No pudo conectarse : " . mysql_error()); if (!$enlace) { die('No conectado : ' . mysql_error()); } $seldb = mysql_select_db($db,$enlace); if (!$seldb) { die ('No se puede usar eventos: ' . mysql_error()); } return $enlace; } function desconectar($conexion){ mysql_close($conexion); } function query($sql){ $res = mysql_query($sql) or die (mysql_error()); return $res; } function buscareventos($ultimo,$mess,$anio){ $conexion = conectar(); $desde = $anio."-".$mess."-01"; $hasta = $anio."-".$mess."-".$ultimo; $sql = "select * from eventos where fecha BETWEEN '$desde' and '$hasta'"; $res = query($sql); if(mysql_num_rows($res) > 1){ echo "<tr><th>FECHA</th><th>EVENTO</th></tr>"; while($fila = mysql_fetch_array($res)){ echo "<tr><td class='tdfecha'>".$fila['fecha']."</td><td class='tdevento'>".$fila['evento']."</td></tr>"; } }else{ echo "<tr><td class='tdno'>No se encuentran eventos cargado en este mes.</td></tr>"; } desconectar($conexion); } function cargarmatriz($ultimo,$mess,$anio){ $i = 0; $conexion = conectar(); $desde = $anio."-".$mess."-01"; $hasta = $anio."-".$mess."-".$ultimo; // $sql = "select * from eventos where fecha BETWEEN '$desde' and '$hasta' order by fecha"; $sql = "select distinct fecha from eventos where fecha BETWEEN '$desde' and '$hasta' order by fecha"; $res = query($sql); if(mysql_num_rows($res) > 0){ while($fila = mysql_fetch_array($res)){ $fecha = $fila['fecha']; $dia = explode("-", $fecha); //if($dias[$i-1] != $dia[2]){ $dias[$i] = $dia[2]; //} $i++; } }else{ $dias[0] = "0"; } desconectar($conexion); return $dias; } function redireccionar($time,$url){ print "<meta http-equiv=Refresh content=\"$time ; url=$url\">"; } ?> Thanks a lot for any help, N.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.