
petri111
New Members-
Posts
4 -
Joined
-
Last visited
Never
Everything posted by petri111
-
Hi, Is this real, nobody can help me???? Where is all php guru's? Please help me!!!! -Petri
-
Hi all, I'm sorry my bad english. I have a problem with my calendar. How I can mark in a date cell half day booked? Which is better image from mysql or do in php code. Have anybody there any example or could you show me how to do? I can get full day mark in my calendar, that is all right, but how I can get half day booked? Now I get full day booked, why my code mark red also empty cells? Here is the code there is not all: calendar.php <?php setlocale(LC_TIME, "fin"); $dbuser="root"; $dbpass=""; $host="localhost"; $yhteys=mysql_connect($host, $dbuser, $dbpass) or die(mysql_error()); if (!$yhteys) { die('Could not connect: ' . mysql_error()); } mysql_select_db("lincal", $yhteys); //$action $tapahtumat = mysql_query("SELECT * FROM tapahtuma" , $yhteys) or die("Kysely ei onnistunut:". mysql_error()); // loop every happens throught and save into array //happenslist $tapahtumalista = array(); while ($row = mysql_fetch_array($tapahtumat)) { $alku = strtotime($row['alko1']); $loppu = strtotime($row['loppu1']); $tapahtumalista[] = array($alku, $loppu); } $month = date('n'); $year = date('Y'); $day = date('j'); echo '<table width="90%" border="0px #009 solid; cellspacing="10" cellpadding="0" style="text-align: center">'; echo "<tr>"; echo "<th></th>"; for ($i=1;$i<=5;$i++) /*these are weekdays*/ echo '<th style="width: 25px;">Ma</th><th style="width: 25px;">Ti</th><th>Ke</th><th style="width: 25px;">To</th><th>Pe</th><th>La</th><th style="width: 30px;">Su</th>'; echo '<th>Ma</th><th>Ti</th>'; //echo "</tr>"; echo '<tr>'; for ($i=0; $i<12; $i++) { //timestamp $aikaleima = mktime(0,0,0,$month+$i,1,$year); $dayofweek = date('w', $aikaleima); $amountofdays = date('t', $aikaleima); //$empties $tyhjia = $dayofweek-1; echo '<td style=\"width: 20px; text-align: center;\"">'.strftime("%B %Y", $aikaleima).'</td>'; //$empties if ($dayofweek == 0) $tyhjia = 6; $tyhjia--; for ($j=-1*$tyhjia; $j<=$amountofdays; $j++) { //this day $tamaPV = mktime(0,0,0,$kk+$i,$j,$vuosi); if($j == date('j') && $i == 0) { echo '<td bgcolor= "yellow" span style="color: red;">'; } else { $tapahtumat = false; //list foreach ($tapahtumalista as $tl) { if ($tl[0] <= $tamaPV && $tl[1] >= $tamaPV) $tapahtumat = true; } if($tapahtumat == true) echo '<td bgcolor="red">'; else echo '<td bgcolor="#91CD92">'; } if ($j>0 && ($i>0 || $j>=date('j'))) echo $j; else echo ' '; echo '</td>'; } echo '</tr>'; } echo '</table>'; mysql_close($yhteys); ?> insert.php <?php $dbuser="root"; $dbpass=""; $host="localhost"; $yhteys=mysql_connect($host, $dbuser, $dbpass) or die(mysql_error()); if (!$yhteys) { die('Could not connect: ' . mysql_error()); } mysql_select_db("lincal", $yhteys); if (isset($_POST['submit'])) { $tunnus = $_POST["tunnus"]; $alko1 = $_POST["alko1"]; $loppu1 = $_POST["loppu1"]; $paiva = explode('.', $alko1); $dd = $paiva[0]; $mm = $paiva[1]; $yyyy = $paiva[2]; $alko1 = $yyyy.'-'.$mm.'-'.$dd; $paiva = explode('.', $loppu1); $dd = $paiva[0]; $mm = $paiva[1]; $yyyy = $paiva[2]; $loppu1 = $yyyy.'-'.$mm.'-'.$dd; $insert = "INSERT INTO tapahtuma (tunnus, alko1, loppu1) VALUES ('$tunnus', '$alko1', '$loppu1')"; if (!mysql_query($insert,$yhteys)) { die('Error: ' . mysql_error()); } } mysql_close($yhteys); ?> Thank's for advance. Help me, please!!!
-
Hi all, I have a problem with my calendar. Can somebody tell me why I can't mark day cells in my calendar. Do I miss something what I can't see or is my code failed? My calendar is full year view calendar and I have start day and end day textboxes, when I click send button days is go to MySql database and should mark day cell to red in calendar at the same time. Days gone to MySql fine. I have a form where is datepicker. Should I do for form something? Here is the code: calendar.php <?php setlocale(LC_TIME, "fin"); $dbuser="root"; $dbpass=""; $host="localhost"; $conn=mysql_connect($host, $dbuser, $dbpass) or die(mysql_error()); if (!$conn) { die('Could not connect: ' . mysql_error()); } mysql_select_db("lincal", $conn); $act = mysql_query("SELECT * FROM action") or die(mysql_error()); $actlist = array(); while($row = mysql_fetch_array($act)) { $start = strtotime($row['start1']); $end = strtotime($row['end1']); $actlist[] = array($start, $end); } $month = date('n'); $year = date('Y'); $day = date('j'); echo '<table width="90%" border="2px #009 solid; cellspacing="10" cellpadding="0" style="text-align: center">'; echo '<tr>'; echo '<th></th>'; for ($i=1;$i<=5;$i++) /*these are weekdays*/ echo '<th style="width: 25px;">Ma</th><th style="width: 25px;">Ti</th><th style="width: 25px;">Ke</th><th style="width: 25px;">To</th><th style="width: 25px;">Pe</th><th style="width: 25px;" bgcolor= "#ECECFF">La</th><th style="width: 25px;" bgcolor= "#E2E2EB">Su</th>'; echo '<th style="width: 25px;">Ma</th><th>Ti</th>'; echo '<tr>'; for ($i=0; $i<12; $i++) { //timestamp $aikaleima = mktime(0,0,0,$month+$i,1,$year); $dayofweek = date('w', $aikaleima); $amountofdays = date('t', $aikaleima); //empties $tyhjia = $dayofweek-1; echo '<td style=\"width: 20px; text-align: center;\"">'.strftime("%B %Y", $aikaleima).'</td>'; //empties if ($dayofweek == 0) $tyhjia = 6; //empties $tyhjia--; for ($j=-1*$tyhjia; $j<=$amountofdays; $j++) { //this day $tamaPV = mktime(0,0,0,$month,1,$year); if($j == date('j') && $i == 0) { echo '<td bgcolor= "yellow" span style="color: red;">'; } else { //act $tapahtuma = false; //actlist foreach ($tapahtumalista as $tl) { //this day //act if ($tl[0] <= $tamaPV && $tl[1] >= $tamaPV) $tapahtuma = true; } //act if ($tapahtuma == true) echo '<td bgcolor="red">'; else echo '<td>'; } if ($j>0 && ($i>0 || $j>=date('j'))) echo $j; else echo ' '; echo '</td>'; } echo '</tr>'; } echo '</table>'; ?> insert.php <?php $dbuser="root"; $dbpass=""; $host="localhost"; $conn=mysql_connect($host, $dbuser, $dbpass) or die(mysql_error()); if (!$conn) { die('Could not connect: ' . mysql_error()); } mysql_select_db('lincal', $conn); if (isset($_POST['submit'])) { $tunnus = $_POST['tunnus']; $start1 = $_POST['start1']; $end1 = $_POST['end1']; //day $paiva = explode('.', $start1); $dd = $paiva[0]; $mm = $paiva[1]; $yyyy = $paiva[2]; $start1 = $yyyy.'-'.$mm.'-'.$dd; //day $paiva = explode('.', $end1); $dd = $paiva[0]; $mm = $paiva[1]; $yyyy = $paiva[2]; $end1 = $yyyy.'-'.$mm.'-'.$dd; $insert = "INSERT INTO action VALUES('$tunnus', '$start1', '$end1')"; if (!mysql_query($insert,$conn)) { die('Error: ' . mysql_error()); } header("Location: kalenteri2.php"); } mysql_close($conn); ?> Can somebody help me, please. Thanks for advance.
-
Hi, Sorry my bad english, if not understanding something I clear case more. I would like to made a calendar which continue automatically when old year end and new year start, how could I made that kind of calendar? This is a linear full year calendar. I mean: M T W T F S S M T W T F S S M T W T F S S November 2010 1 2 3 4 5 6 7 8 9 10 11 12 13 14... December 2010 1 2 3 4 5 6 7 8 9 10 11 12 13 14... January 2011 1 2 3 4 5 6 7 8 9 10 11 12 13 14... February 2011 1 2 3 4 5 6 7 8 9 10 11 12 13 14... March 2011 and so on... I have a little bit of code made, but I don't know how the calendar understand when its change year. Here is the code below what I made now. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//FI" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi" lang="fi"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" /> <title>Linear Calendar</title> <style type="text/css" media="all"> body { font-family:"Calibri"; color:#009; } .thisDay { background:#FFC; color:red; } table { border-collapse:collapse; border:1px #009 solid; } td { height:20px; vertical-align:top; text-align:center; width:30px; border:1px #009 solid; } th{ height:30px; width:30px; } .dday:hover { background:#9F0; border-color:#000; } .day6 { background:#ECECFF; } .day7 { background:#E2E2EB; } .kkNimi { text-align:left; vertical-align:middle; } .kkNimi div { padding-left:5px; padding-right:5px; width:160px; } .days{ background:#DDDEDE; } </style> </head> <body> <table width="80%" border="1" cellspacing="0" cellpadding="0"> [code=php:0] <?php $password=""; $user="root"; $host="localhost"; $yhteys=mysql_connect($host, $user, $password) or die(mysql_error()); mysql_select_db("lincal",$yhteys) or die(mysql_error()); $DaysinPage = 36; $dDay = 1; if (isset($_POST['year'])) { $year = $_POST['year']; } else { $year = date ('Y'); } function setYear ($year) { // Check year if (is_numeric ($year) && $year % 1 == 0 && $year > 2010 && $year < 2038) $this -> year = $year; else $this -> year = date ('Y'); return true; } if((isset($_GET['d']))?$dDay=$_GET['d']:$dDay = date("d")); if((isset($_GET['m']))?$month=$_GET['m']:$month = date("n")); if((isset($_GET['y']))?$year=$_GET['y']:$year = date("n")); echo "<tr>\r\n"; echo "<th></th>"; // blank header to compensate for row labels for ($i=1;$i<=5;$i++) // do this 5 times... echo "<th>Ma</th><th>Ti</th><th>Ke</th><th>To</th><th>Pe</th><th>La</th><th>Su</th>\r\n"; echo "<th>Ma</th><th>Ti</th>\r\n"; // if the first falls on Sat, we could need 37 boxes echo "</tr>\r\n"; $months=array(); $months[1]="Jan"; $months[2]='Feb'; $months[3]='Mar'; $months[4]='Apr'; $months[5]='May'; $months[6]='Jun'; $months[7]='Jul'; $months[8]='Aug'; $months[9]='Sep'; $months[10]='Oct'; $months[11]='Nov'; $months[12]="Dec"; $months[13]='Jan'; $months[14]='Feb'; $months[15]='Mar'; $months[16]='Apr'; $months[17]='May'; $months[18]='Jun'; $months[19]='Jul'; $months[20]='Aug'; $months[21]='Sep'; $months[22]='Oct'; $months[23]='Nov'; $months[24]="Dec"; $days_of_month=array(); $days_of_month[1]=31; if (date("Y")%4==0) $days_of_month[2]=29; else $days_of_month[2]=28; $days_of_month[3]=31; $days_of_month[4]=30; $days_of_month[5]=31; $days_of_month[6]=30; $days_of_month[7]=31; $days_of_month[8]=31; $days_of_month[9]=30; $days_of_month[10]=31; $days_of_month[11]=30; $days_of_month[12]=31; $days_of_month[13] =31; if (date("Y")%4==0) $days_of_month[14]=29; else $days_of_month[14]=28; $days_of_month[15]=31; $days_of_month[16]=30; $days_of_month[17]=31; $days_of_month[18]=30; $days_of_month[19]=31; $days_of_month[20]=31; $days_of_month[21]=30; $days_of_month[22]=31; $days_of_month[23]=30; $days_of_month[24]=31; $first_of_month=array(); for ($i=6;$i<=17;$i++) // do this for each of the 12 months { $timestamp=strtotime($months[$i]." 0 ".$year); $first_of_month[$i]=date("w",$timestamp); // day of the week as a number (0-6) } $year=date("Y"); $dDay=date("j"); $month=date("n"); $next = $year + 1; $months = array("Tammikuu $year", "Helmikuu $year", "Maaliskuu $year", "Huhtikuu $year", "Toukokuu $year", "Kesäkuu $year", "Heinäkuu $year", "Elokuu $year", "Syyskuu $year", "Lokakuu $year", "Marraskuu $year", "Joulukuu $year", "Tammikuu $next", "Helmikuu $next", "Maaliskuu $next", "Huhtikuu $next", "Toukokuu $next", "Kesäkuu $next", "Heinäkuu $next", "Elokuu $next", "Syyskuu $next", "Lokakuu $next", "Marraskuu $next", "Joulukuu $next"); for($i=6;$i<=17;$i++) { echo "<tr><td class='kkNimi'><div>".$months[$i-1]."</div></td>"; if ($i<$month) // if the month is passed... { for ($j=1;$j<=$DaysinPage;$j++) echo "<td> </td>"; } // end if($i<$month) elseif ($i>$month) // month is in the future { $counter=0; // count of up to 37 day blocks for ($j=1;$j<=$first_of_month[$i];$j++) // number of blank spaces before... { echo "<td> </td>"; $counter++; // increment counter } for ($j=1;$j<=$days_of_month[$i];$j++) // number of date boxes { echo "<td>".$j."</td>"; $counter++; } for ($j=1;$j<=($DaysinPage-$counter);$j++) // end boxes { echo "<td> </td>"; } } // end elseif ($i>$month) else // current month { $counter=0; for ($j=1;$j<=($first_of_month[$i]+$dDay-1);$j++) // preceding blanks { echo "<td></td>"; $counter++; } echo "<td><font color=\"red\">".$dDay."</font></td>"; // today's day in red $counter++; for ($j=$dDay+1;$j<=$days_of_month[$i];$j++) //remaining days of month { echo "<td>".$j."</td>"; $counter++; } for ($j=1;$j<=($DaysinPage-$counter);$j++) // remaining blanks { echo "<td></td>"; } //echo "\r\n"; // line break } //end else -- current month }// end of for($i=1;$i<=12;$i++) echo "</table>"; function echoSelectDate ($prefix, $date, $disabled = false, $onchange = false) { $r = ''; $selected = array_reverse (explode ('-', $date)); $selects = array ( array ( 'name' => 'D', 'start' => 1, 'end' => 31 ), array ( 'name' => 'M', 'start' => 1, 'end' => 12 ), array ( 'name' => 'Y', 'start' => 2010, 'end' => 2037 ) ); for ($i = 0; $i < 3; $i ++) { $r .= '<select name="' . $prefix . $selects[$i]['name'] . '" id="' . $prefix . $selects[$i]['name'] . '" size="1"'; if ($disabled) $r .= ' disabled="disabled"'; if ($onchange) $r .= ' onchange="' . $onchange . '"'; $r .= '>'; for ($j = $selects[$i]['start']; $j <= $selects[$i]['end']; $j ++) { $r .= '<option value="' . $j . '"'; if ($j == $selected[$i]) $r .= ' selected="selected"'; $r .= '>' . $j . '</option>'; } $r .= '</select>'; } return $r; } mysql_close($yhteys) ?> </table> </body> </html> [/code] Thanks for advance for help. -Petri