Note that there are some explanatory texts on larger screens.

plurals
  1. POcalendar not showing correct members events
    text
    copied!<p>i have a website with multiple members, i want each if them to have their own calendar. i found a tutorial to build and events calendar witch works fine but i am having trouble trying to get the events to show on the correct calendar, either everyone can see all events in the database or no one can see any.</p> <p>my code is as follows</p> <p>calendar_start.php</p> <pre><code>&lt;?php $showmonth = $_POST['showmonth']; $showyear = $_POST['showyear']; $showmonth = preg_replace('#[^0-9]#i', '', $showmonth); $showyear = preg_replace('#[^0-9]#i', '', $showyear); $day_count = cal_days_in_month(CAL_GREGORIAN, $showmonth, $showyear); $pre_days = date('w', mktime(0,0,0, $showmonth, 1, $showyear)); $post_days = (6 - (date('w', mktime(0,0,0, $showmonth, $day_count, $showyear)))); echo '&lt;div id="calender_wrap"&gt;'; echo '&lt;div class="title_bar"&gt;'; echo '&lt;div class="previouse_month"&gt;&lt;input name="myBtn" type="submit" value="Previouse Month" onclick="javascript:last_month();"&gt;&lt;/div'; echo '&lt;div class="show_month"&gt;' . $showmonth . '/' . $showyear . '&lt;/div&gt;'; echo '&lt;div class="next_month"&gt;&lt;input name="myBtn" type="submit" value="Next Month" onclick="javascript:next_month();"&gt;&lt;/div&gt;'; echo '&lt;/div&gt;'; echo '&lt;div class="week_days"&gt;'; echo '&lt;div class="days_of_week"&gt;Sunday&lt;/div&gt;'; echo '&lt;div class="days_of_week"&gt;Monday&lt;/div&gt;'; echo '&lt;div class="days_of_week"&gt;Tuesday&lt;/div&gt;'; echo '&lt;div class="days_of_week"&gt;Wednesday&lt;/div&gt;'; echo '&lt;div class="days_of_week"&gt;Thursday&lt;/div&gt;'; echo '&lt;div class="days_of_week"&gt;Friday&lt;/div&gt;'; echo '&lt;div class="days_of_week"&gt;saturday&lt;/div&gt;'; echo '&lt;div class="clear"&gt;&lt;/div&gt;'; echo '&lt;/div&gt;'; /* Previouse Month filler Days */ if ($pre_days != 0) { for($i = 1; $i&lt;=$pre_days; $i++) { echo '&lt;div class="non_cal_day"&gt;&lt;/div&gt;'; } } /*Current Month filler Days */ include("scripts/connect_to_mysql.php"); for($i = 1; $i&lt;= $day_count; $i++) { // get event logic $date = $i . '/' . $showmonth . '/' . $showyear; $query = "SELECT * FROM occurrences WHERE cid ='$squadid' AND start_date ='$date' "; $cal = mysqli_query($db_conx, $query); $num_rows = mysqli_num_rows($cal); if($num_rows &gt; 0) { $event= '&lt;a href="view_events.php"&gt;&lt;h3 class="event_here"&gt;Events Here&lt;/h3&gt;&lt;/a&gt;'; } //end get event logic echo '&lt;div class="cal_day"&gt;'; echo '&lt;div class="day_heading"&gt;' . $i . ' &lt;a href="add_event.php"&gt;&lt;div class="add_event"&gt;&lt;/div&gt;&lt;/a&gt;&lt;/div&gt;&lt;br/&gt;'; if($num_rows != 0) { echo $event;} echo '&lt;/div&gt;'; } /* Next month filler days */ if ($post_days != 0) { for($i = 1; $i&lt;=$post_days; $i++) { echo '&lt;div class="non_cal_day"&gt;&lt;/div&gt;'; } } echo '&lt;/div&gt;'; ?&gt; </code></pre> <p>show_calendar.php</p> <pre><code>&lt;?php // Start_session, check if user is logged in or not, and connect to the database all in one included file include_once("scripts/checkuserlog.php"); // Include the class files for auto making links out of full URLs and for Time Ago date formatting include_once("wi_class_files/autoMakeLinks.php"); include_once ("wi_class_files/agoTimeFormat.php"); // Create the two new objects before we can use them below in this script $activeLinkObject = new autoActiveLink; $myObject = new convertToAgo; // ------- ESTABLISH THE PAGE ID ACCORDING TO CONDITIONS --------- $squadid = ""; if (isset($_GET['pid'])){ $squadid = $_GET['pid'];}; // ------- END ESTABLISH THE PAGE ID ACCORDING TO CONDITIONS --------- //-------- GET EVENTS FROM TABLE------------------------------------- ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;Calender&lt;/title&gt; &lt;link href="style/calCss.css" rel="stylesheet" type="text/css" media="all" /&gt; &lt;link href="style/main.css" rel="stylesheet" type="text/css" /&gt; &lt;link rel="icon" href="logoicon.ico" type="image/x-icon" /&gt; &lt;link rel="shortcut icon" href="logoicon.ico" type="image/x-icon" /&gt; &lt;script language="javascript" type="text/javascript"&gt; function initialCalendar() { var hr = new XMLHttpRequest(); var url = "calender_start.php"; var currentTime = new Date(); var month = currentTime.getMonth() + 1; var year = currentTime.getFullYear(); showmonth = month; showyear = year; var vars = "showmonth="+showmonth+"&amp;showyear="+showyear; hr.open("POST", url, true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function() { if(hr.readyState == 4 &amp;&amp; hr.status == 200) { var return_data = hr.responseText; document.getElementById("showCalendar") .innerHTML = return_data; } } hr.send(vars); document.getElementById("showCalendar") .innerHTML = "processing..."; } &lt;/script&gt; &lt;script language="javascript" type="text/javascript"&gt; function next_month() { var nextmonth = showmonth + 1; if(nextmonth &gt; 12) { nextmonth = 1; showyear = showyear + 1; } showmonth = nextmonth; var hr = new XMLHttpRequest(); var url = "calender_start.php"; var vars = "showmonth="+showmonth+"&amp;showyear="+showyear; hr.open("POST", url, true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function() { if(hr.readyState == 4 &amp;&amp; hr.status == 200) { var return_data = hr.responseText; document.getElementById("showCalendar").innerHTML = return_data; } } hr.send(vars); document.getElementById("showCalendar").innerHTML = "processing..."; } &lt;/script&gt; &lt;script language="JavaScript" type="text/javascript"&gt; function last_month() { var lastmonth = showmonth - 1; if(lastmonth &lt; 1) { lastmonth = 12; showyear = showyear - 1; } showmonth = lastmonth; var hr = new XMLHttpRequest(); var url = "calender_start.php"; var vars = "showmonth="+showmonth+"&amp;showyear="+showyear; hr.open("POST", url, true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function() { if(hr.readyState == 4 &amp;&amp; hr.status == 200) { var return_data = hr.responseText; document.getElementById("showCalendar").innerHTML = return_data; } } hr.send(vars); document.getElementById("showCalendar").innerHTML = "processing..."; } &lt;/script&gt; &lt;/head&gt; &lt;body onload="initialCalendar();"&gt; &lt;?php include_once "header_template.php"; ?&gt; &lt;table class="mainBodyTable" border="0" align="center" cellpadding="0" cellspacing="0"&gt; &lt;tr&gt; &lt;td width="740" valign="top"&gt;&lt;div&gt;&lt;?php include_once "leaderBoardAd.php"; ?&gt;&lt;/div&gt;&lt;br /&gt; &lt;table width="90%" align="center" cellpadding="6"&gt; &lt;tr&gt; &lt;td&gt; &lt;div id="showCalendar"&gt;&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;&lt;/td&gt; &lt;td width="160" valign="top"&gt;&lt;?php include_once "right_AD_template.php"; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;?php include_once "footer_template.php"; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>currently if i remove the <code>cid ='$squadid'</code> from the <code>$query</code> in calendar_start.php you can see all events in the database but every member on the site can also see them.</p> <p>in my table the <code>cid</code> should stand for calendar id ie. the members own calendar but i cannot work out where i am going wrong.</p> <p>i hope i have explained this well enough but if you need more just let me know.</p> <p>many thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload