Forum Moderators: coopster

Message Too Old, No Replies

My final problem and then project complete! - Calendar links

         

nshack31

12:08 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



I am using this function to read from my DB and place a link on the calendar if there is a match on that day..


function getDateLink($day, $month, $year)
{
include 'open.php';
GLOBAL $cnt; //$cnt has the value 0 as specified before
$cnt = 0; // Resetting $cnt to 0


$query="Select * From challenge Where confirmed = 'Yes' AND played = 'No' AND month = '$month' AND year = '$year' AND day = '$day'";

$result = mysql_query($query);

$clanday='';
$clanmonth='';
$clanyear='';
$link = '';

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$clanday[]=$row['day'];
$clanmonth[]=$row['month'];
$clanyear[]=$row['year'];

$cnt++;
if(in_array($day,$clanday) and in_array($month,$clanmonth) and in_array($year,$clanyear))
{
$link = "displaymatches.php?day=$day&month=$month&year=$year";
}

}

return $link;
include 'close.php';

}

The problem is that this calendar only shows future matches from the CHALLENGE table. I need to also select values from my PLAYED table and have them inserted onto that calendar. Can anybody help?!

thanks

[edited by: jatar_k at 5:19 pm (utc) on Mar. 29, 2005]
[edit reason] removed url [/edit]

wrightee

12:30 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



Just rewrite your query to read from two tables instead:

$query="Select challenge.day as cday,challenge.month as cmonth, challenge.year as cyear, played.day as pday, played.month as pmonth, played.year as pyear From challenge,played" .... etc

You'll need to specify which tables to use in your WHERE clause or it will complain about ambiguity.

nshack31

12:39 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



ah thanks i was unsure howto make my query read from two tables! super.

Would I also need to edit the while statement? what would.. $clanday[]=$row['day']; become? as it is called "day" in both tables

And then change my if statement to something like...

if(in_array($day,$clanday) and in_array($month,$clanmonth) and in_array($year,$clanyear) OR in_array($day,$pldday) and in_array($month,$pldmonth) and in_array($year,$pldyear) )