Hey guys, i have a problem with my script and iam not sure if it is possible to do this. I want to apply the ShowTimeD function to both the "time" and "$today" variable so they are both formatted correctly to match. It give me a error when trying to do this.... i know for a fact that the dates match up, since i did some outside unit testing. $EventQuery = $this->query("SELECT * FROM events WHERE ShowTimeD(time = '$today') LIMIT 1"); Code (markup): Any help would be great, thanks!
So i inputed your new code and im still not getting a match, this is the whole code .... The $date and $actday are just variables that define what day it is.... function CalendarCheck($date, $actday) { $EventQuery = $this->query("SELECT * FROM events WHERE ShowTimeD(time) = ShowTimeD('{$date}') LIMIT 1"); //if rows are true lets print it out! if($this->num_rows($EventQuery)){ //it is true, get information $EventMatch = $this->fetch_array ($EventQuery); echo '<div id="calsubdate" class="link"><a href="'.$EventMatch[eid].'">$actday</a></div>'; }else{ //display the no link echo "<div id=\"calsubdate\">".$actday."</div>\n"; } } Code (markup):
I had assumed that ShowTimeD was a function you'd created in MySQL. Is it a PHP function? In that case I don't think I understand well enough what you're trying to do. What does the function do? What do the MySQL fields look like? What are you trying to achieve?
Ok sorry for the confusion...ShowTimeD is a php function inside inside a functions file. what im trying to do is echo out my calendar and once if is ready to output a certain day, I am trying to get it to check to see if an event is present on that day. The date in the database is formated like this 2013-04-20 17:03:01 , basically like a timestamp this is the code for my ShowTimeD function: function ShowTimeD($date) { return date("m/d/y", strtotime($date)); } //function ShowTimeD($date) Code (markup): This is the code for my calendar thats being outputed: class Calendar extends Database{ function showCalendar($year=0,$month=0){ // Get today, reference day, first day and last day info if (($year == 0) || ($month == 0)){ $referenceDay = getdate(); } else { $referenceDay = getdate(mktime(0,0,0,$month,1,$year)); } $firstDay = getdate(mktime(0,0,0,$referenceDay['mon'],1,$referenceDay['year'])); $lastDay = getdate(mktime(0,0,0,$referenceDay['mon']+1,0,$referenceDay['year'])); $today = getdate(); // Create a table with the necessary header informations echo '<div id="calender"><div id="calheader">- '.$referenceDay['month'].' - '.$referenceDay['year'].' -</div>'; echo '<!-- Days of the week --> <div id="calsubhead">Mo</div> <div id="calsubhead">Tu</div> <div id="calsubhead">We</div> <div id="calsubhead">Th</div> <div id="calsubhead">Fr</div> <div id="calsubhead">Sa</div> <div id="calsubhead">Su</div> <!-- End Days of the week -->'; // Display the first calendar row with correct positioning echo '<!-- Begin Dates -->'; if ($firstDay['wday'] == 0) $firstDay['wday'] = 7; for($i=1;$i<$firstDay['wday'];$i++){ echo "<div id=\"calsubdate\"> </div>\n"; } $actday = 0; for($i=$firstDay['wday'];$i<=7;$i++){ $actday++; //check if event is on day //echo $this->CalendarCheck(date('Y-m-'.$actday.''), $actday); $this->CalendarCheck(date("2008-01-22 01:00:01"), $actday); } //Get how many complete weeks are in the actual month $fullWeeks = floor(($lastDay['mday']-$actday)/7); for ($i=0;$i<$fullWeeks;$i++){ for ($j=0;$j<7;$j++){ $actday++; //check if event is on day //echo $this->CalendarCheck(date('Y-m-'.$actday.''), $actday); $this->CalendarCheck(date("2008-01-22 01:00:01"), $actday); } } //Now display the rest of the month if ($actday < $lastDay['mday']){ for ($i=0; $i<7;$i++){ $actday++; if ($actday <= $lastDay['mday']){ //there is a date, check the database! //check if event is on day //echo $this->CalendarCheck(date('Y-m-'.$actday.''), $actday); $this->CalendarCheck(date("2008-01-22 01:00:01"), $actday); } else { echo "<div id=\"calsubdate\"> </div>\n"; } } } echo '</div>'; echo '<!-- End Dates -->'; } //check to see if we have a make in db function CalendarCheck($date, $actday) { $EventQuery = $this->query("SELECT * FROM events WHERE ShowTimeD(time) = ShowTimeD('{$date}') LIMIT 1"); //if rows are true lets print it out! if($this->num_rows($EventQuery)){ //it is true, get information $EventMatch = $this->fetch_array ($EventQuery); echo '<div id="calsubdate" class="link"><a href="'.$EventMatch[eid].'">$actday</a></div>'; }else{ //display the no link echo "<div id=\"calsubdate\">".$actday."</div>\n"; } } } Code (markup):