I am trying to design an events calender, I have created a page to input hte data and everything works fine. I am having trouble on the viewing page getting the data from the data base. Here is the code
[php]
<?php $db_addr = "somehost"; $db_name = "somedatabase"; $db_user = "someuser"; $db_pass = "somepass"; $table_name = "main"; $table_name = "times"; header("Expires: ".gmdate("D, d M Y H:i:s")." GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); header("Cache-Control: post-check=0, pre-check=0"); $months = array( "01" => "January", "02" => "February", "03" => "March", "04" => "April", "05" => "May", "06" => "June", "07" => "July", "08" => "August", "09" => "September", "10" => "October", "11" => "November", "12" => "December" ); if (!$dbh = @mysql_connect($db_addr, $db_user, $db_pass)): die ("Connection to the data base server could not be made."); endif; // MySQL data base auswaele if (!$dbdat = @mysql_select_db($db_name, $dbh)): die ("Database could not be selected."); endif; function table_exists($table) { GLOBAL $db_name; $result = mysql_list_tables ($db_name); if (!$result) {echo "Examination of the tables could not be accomplished.";} else { while($row = mysql_fetch_row($result)){ if ($row[0] == $table) return true; } } return false; } function check_date($d, $m, $Y){ if (date("m-d-Y", mktime(0, 0, 0, $m, $d, $Y)) == "$m-$d-$Y") return true; return false; } function daysinmonth($month, $year) { if(checkdate($month, 31, $year)) return 31; if(checkdate($month, 30, $year)) return 30; if(checkdate($month, 29, $year)) return 29; if(checkdate($month, 28, $year)) return 28; return 0; } function weeksinmonth($month, $year){ $firstDay = array ("01", $month, $year); $lastDay = array (daysinmonth($month, $year), $month, $year); $tst1 = mktime (1, 0, 0, $firstDay[1], $firstDay[0], $firstDay[2]); $tst2 = mktime (1, 0, 0, $lastDay[1], $lastDay[0], $lastDay[2]); $wa = date("W", $tst1); $we = date("W", $tst2); if ($wa == 53) $wa = 1; $weeks = $we - $wa; return array($weeks, $wa, $we); } function get_time ($tst){ Global $timestring; $lok = date($timestring, $tst); return (!empty ($tst)) ? $lok : ""; } $plan_nr = (empty($_GET['plan_nr'])) ? 1 : $_GET['plan_nr']; $year = (empty($_GET['year'])) ? date("Y", time()) : $_GET['year']; $month = (empty($_GET['month'])) ? date("m", time()) : $_GET['month']; $week_days = array(0, 1, 2, 3, 4, 5, 6); $tarr = array(); if (isset($_GET['plan_nr'])) $gnr = "&plan_nr=".$_GET['plan_nr']; $cur_month = date("m", time()); $y = date("Y", time()); $yk = substr ($y, 2, 2); $month1 = $months['01']; $month2 = $months['02']; $month3 = $months['03']; $month4 = $months['04']; $month5 = $months['05']; $month6 = $months['06']; $month7 = $months['07']; $month8 = $months['08']; $month9 = $months['09']; $month10 = $months['10']; $month11 = $months['11']; $month12 = $months['12']; $error = false; $alloc_month = array(); $query = "SELECT * FROM $main_table_name WHERE plan_nr = '$plan_nr' AND YEAR(alloc) = '$year' AND MONTH(alloc) = '$month'"; if ($result = mysql_query($query)) { while ($row = mysql_fetch_array ($result)){ $alloc_month[] = $row["alloc"]; } } asort ($alloc_month); list ($weeks, $first, $last) = weeksinmonth($month, $year); $week_table = ""; $days = 0; $days = daysinmonth($month, $year); $tm = date("w", mktime(1, 0, 0, $month, 1, $year)); for ($i = 0; $i <= $weeks; $i++){ $week_table .= "
[/php]
The page views like this
http://ww2.apartmentloscristianos.me.uk/cal/view.php
I can get results for an individual month but not all the months. I can get results if I use a tabular display but It doesnt look right within the site
Does anybody have any ideas