473,385 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

event calendar problem

I have a clickable calendar, which user can select the day that they
want to view the news linking to. My calendar has the clickable event
day, but once the user click it, the day selected could not be parsed
to the mysql queries retrieval. $d has problem. How do I tackle this
$d? The code is a bit long....

<html>
<head>
<title>Calendar</title>
<body>
<form action="cal_new1.php" method="post">

<h3>Please select month or year:</h3>

<select name="month">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
/
<select name="year">
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
</select>
<input type="submit" value="Display Calendar" />

<?php

$db = mysql_connect("localhost", "root", "") or die(mysql_error());

mysql_select_db("bulletin", $db) or die(mysql_error());

//generate event calendar
echo createcal($month, $year);
if (isset($_POST['d']))
{
echo "kjkljlk";
$d = $_POST['d'];
echo "d=".$d;
}

else
{
echo "183439";
$d = date("Y-n-j");
echo "d=".$d;
}

//show news and events
$show = "SELECT * FROM `bul_data` WHERE `DATE` LIKE '$d 22:36:40'";
echo "show=".$show;

$showres = mysql_query($show) or die(mysql_error());

if(mysql_num_rows($showres)>0)
{

while ($showrow = mysql_fetch_assoc($showres))
{
$day = $showrow['DATE'];
$title = $showrow['TITLE'];
$department = $showrow['DEPARTMENT'];
$campus = $showrow['CAMPUS'];
$link = $showrow['LINK'];

echo "<p>$day</p>\n";
echo "<p>$title</p>\n";
echo "<p>$department</p>\n";
echo "<p>$campus</p>\n";
echo "<p><a href=\"$link\">$link</a></p>\n";

}
}

else
{
echo "<p>No news available</p>";
}
function createcal($month, $year)
{

$month = "";
$year = "";

//get year & month from the calendar
if (isset($_POST['month']) && isset($_POST['year']))
{
$month = $_POST['month'];
echo "post_month=".$month;
$year = $_POST['year'];
echo "post_year=".$year;

}
else
{
$components = getdate();
$month = $components['mon'];
$year = $components['year'];
}

echo "month=".$month;

echo "year=".$year;

$output = "<h1>Bulletins for $month / $year</h1>";

//create event days
$newsquery = "SELECT `DATE` FROM `bul_data`";
echo "newsquery=".$newsquery;

$newsres = mysql_query($newsquery) or die(mysql_error());

$eventday = array();

if(mysql_num_rows($newsres)>0)
{

while ($newsrow = mysql_fetch_assoc($newsres))
{
$date = $newsrow['DATE'];
echo "date=".$date;

$eventday[] = $date;
echo "eventday=".$eventday;
}
}

//create table tag opener and day headers
$output .="<table border=\"1\">\n";

$output .="<tr>";

$days = array("SUN","MON","TUE","WED","THU","FRI","SAT");

foreach($days as $day)
{
//create calendar headers
$output .="<th><b>$day</th>\n";

}

$output .="</tr>";

//get 1st day of month
$start = mktime(0,0,0,$month,1,$year);
echo "start=".$start;
$thisdate = getdate($start);

$firstweekday = $thisdate['wday'];
echo "firstweekday=".$firstweekday;

//calculate number of days in the current month
$maxday = date('t', $start);
echo "maxday=".$maxday;

//$next_month = getDate(mktime(0, 0, 0, $month + 1, 1, $year));
//echo "next_month=".$next_month;
$output .="<tr>";

//align first week of month
for($cday = 0; $cday < $firstweekday; $cday++)
{
$output .="<td>&nbsp</td>\n";
}
//display days of remaining weeks
for($counter = 1; $counter <= $maxday; $counter++)
{
$firstweekday %= 7;
$ripdate = "$year-$month-$counter 22:36:40";
echo "ripdate=".$ripdate;
$d = $year."-".$month."-".$counter;
echo "d=".$d;

//construct new row if 7th column is reached
if($firstweekday == 0)
{
//$firstweekday =0;
$output .="</tr><tr>";
echo "skjsksl";

if (in_array($ripdate, $eventday))
{
echo "2iuwiruo";
$output .="<td class=\"post\"><a href=\"news.php?$year-$month-
$counter\">$counter</a>";
$output .="<input name=\"d\" type=\"text\" type=\"hidden\" value=
\".$d.\"></td>\n";
}

else
{
echo "qoiwwo";
$output .="<td class=\"empty\">$counter</td>\n";
}
}

//not yet reach last column, continue to display
else
{
if (in_array($ripdate, $eventday))
{
echo "sqpoipo";
$output .="<td class=\"post\"><a href=\"news.php?$year-$month-
$counter\">$counter</a>";
$output .= "<input name=\"d\" type=\"text\" type=\"hidden\" value=
\".$d.\"></td>\n";
}

else
{
echo "$%%^^&**@";
$output .="<td class=\"empty\">$counter</td>\n";
}
}
$firstweekday++;
echo "counter=".$counter;
}

//$restday = getdate(mktime(0, 0, 0, $month, $maxday, $year));
//for ($cday = $restday+1; $cday < 7; $cday++)
//{
// $output .="<td>&nbsp</td>";
//}

$output .="</tr>";
$output .="</table>";
$output .="</form>";

return $output;

}

?>

</body>
</html>

Jan 30 '07 #1
6 1694
Code was quite long to anyone debug for your behalf.

GENERAL HINT #1:

var_dump($_REQUEST);
do that sometimes to check if post&get-variables are received in a way you
thought they are.

GENERAL HINT #2;

concanate sql query parts into one string and print that instead of
excetuting. copy then it from the screen and use phpmyadmin to check what
query really returns or is it valid syntax at all.

Jan 30 '07 #2
Yes, I had checked with $_REQUEST['d'], and it's giving same results
where d does not parse the value of the selected day. Besides, the
mysql syntax is also correct when I tried to input the fixed date, and
it is able to print out the news on the correspond day.

Does it need the proper assignment of d array? i.e. d[], or
d[$counter] ? I've changed 'd' for either case of d[] and
d[$counter], but it is still doesn't work though.

Jan 31 '07 #3

"caine" <th*********@gmail.comkirjoitti
viestissä:11*********************@v33g2000cwv.goog legroups.com...
Yes, I had checked with $_REQUEST['d'], and it's giving same results
where d does not parse the value of the selected day. Besides, the
mysql syntax is also correct when I tried to input the fixed date, and
it is able to print out the news on the correspond day.

Does it need the proper assignment of d array? i.e. d[], or
d[$counter] ? I've changed 'd' for either case of d[] and
d[$counter], but it is still doesn't work though.

Jan 31 '07 #4
Are you going to secobd page trough form (submit button) or trough link?
Is the second script with the problem news.php OR cal_new1.php?

if (in_array($ripdate, $eventday))
{
echo "2iuwiruo";
$output .="<td class=\"post\"><a href=\"news.php?$year-$month-
$counter\">$counter</a>";
$output .="<input name=\"d\" type=\"text\" type=\"hidden\" value=
\".$d.\"></td>\n";
}
Jan 31 '07 #5
er.... actually problem with the linking <a href....>. i'd solved the
problem. juz lacking of concatenation with the variable in the hidden
form in <a hrefstatement, that is "d=". tq so much

Feb 4 '07 #6
I wanted to add current date and shade the day with different color.
However, I've tried and it works when the $_POST['month']) and
$_POST['year'] are empty. I added these:

$currentday = $components['mday'];

if($currentday == $counter)
$rip_currentday = "$year-$month-$currentday 22:36:40";

//construct new row if 7th column is reached
if($firstweekday == 0)
{
//$firstweekday =0;
$output .="</tr><tr>";
echo "skjsksl";

if (in_array($ripdate, $eventday))
{

if (in_array($rip_currentday, $eventday) && $currentday ==
$counter)
{
echo "today";
$output .="<td class=\"today\"><a href=\"viewnews.php?d=$year-
$month-$counter\" target=\"_blank\">$counter</a>";
$output .="<input name=\"d\" type=\"text\" type=\"hidden\" value=
\".$d.\"></td>\n";

}

else
{
echo "2iuwiruo";
$output .="<td class=\"event\"><a href=\"viewnews.php?d=$year-
$month-$counter\" target=\"_blank\">$counter</a>";
$output .="<input name=\"d\" type=\"text\" type=\"hidden\" value=
\".$d.\"></td>\n";
}
}

else
{

if ($currentday == $counter)
{
echo "else_today";
$output .="<td class=\"today\">$counter</td>\n";
}
else
{
echo "qoiwwo";
$output .="<td>$counter</td>\n";
}
}

}

I hope to get current day displayed althought the $_POST['month']) and
$_POST['year'] are "isset". I inserted the $currentday =
$components['mday']; in the isset loop, but it appears to have the
similar number shaded with different color whenever I change to next
month or previous month. Can anybody help?
Feb 8 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Aymer | last post by:
i created a new button object. how do i attach an event on it? thanx for your help. Dim cc As ColorConverter = new ColorConverter() Dim b = new button() b.ID = "SelectedDate" b.BorderStyle...
2
by: jv | last post by:
Hello, I have a Service Cancellation form that contain a CancelDate text box. The text box has an AfterUpdate event that perform a few calculations. This works fine. However, next to the text...
3
by: David | last post by:
Hi I use a calendar to update a field and the after update event no longer works, if i manually update it there is not a problem. How can I get this event to trigger Thanks in advance Dave
2
by: Xela | last post by:
Hi all, I have radio button list in a user control which when selection changed fire an event which will modify the current Thread culture. This user control is on general page which contain...
0
by: Mariano Padilla | last post by:
I have a form that has 12 Calendar, 1 for each month. I am retrieving information from a database separately, assigning them to an array and then in the DayRender Event, itterating through the...
5
by: Bob | last post by:
The title says it all. The nextmon() and prevmon() functions are listed afterward, since they call fDrawCal().I'm sure you see the problem...prevmon() is not defined prior to being mentioned in the...
6
by: Murray Hopkins | last post by:
Hi. THE QUESTION: How do I get a reference to my Object when processing an event handler bound to an html element ? CONTEXT: Sorry if it is a bit long. I am developing a JS calendar tool....
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
2
by: markszlazak | last post by:
Could someone check out the following code and please help me understand the problem and fix it. It seems like some events are not firing when my mouse moves over the table cells to quickly causing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.