我在我的项目中使用php,我正在使用JavaScript日历。我的数据库中有一个事件日期,我想在我的日历中突出显示。我尝试了以下代码:
PHP
$items = '';
$selq = mysql_query("SELECT * FROM ".$gettn." WHERE template_content_id = '$gettid'");
$fetselq = mysql_fetch_array($selq);
$linkId1 = $fetselq['id'];
$getevent1 = mysql_query("SELECT * FROM `template3event` WHERE tl3_id = '$linkId1'");
//$items = array();
while($fetcgetevent1 = mysql_fetch_array($getevent1)){
$items .= date('d-F', strtotime($fetcgetevent1['date'])).',';
}
$event_date = substr($items, 0, -1);
$event_dates = explode(',', $event_date);
$Event_count = substr_count($event_date , ',');
// for($z = 0; $z <= $Event_count; $z++){
// echo $event_dates[$z].'<br>';
// }
// fill the month table with column headings
function day_title(day_name){
document.write("<TD ALIGN=center WIDTH=35>"+day_name+"</TD>")
}
// fills the month table with numbers
function fill_table(month,month_length)
{
day=1
// begin the new month table
document.write("<DIV CLASS='calender slide1'><P>"+month+" "+year+"</P>")
document.write("<TABLE width='240'><TR>")
// column headings
day_title("S")
day_title("M")
day_title("T")
day_title("W")
day_title("T")
day_title("F")
day_title("S")
// pad cells before first day of month
document.write("</TR><TR>")
for (var i=1;i<start_day;i++){
document.write("<TD>")
}
// fill the first week of days
for (var i=start_day;i<8;i++){
document.write("<TD><a href='#'>"+day+"</a></TD>")
day++
}
document.write("<TR>")
// fill the remaining weeks
while (day <= month_length) {
for (var i=1;i<=7 && day<=month_length;i++){
var getcurrentmonth= $('#hiddenmonth').val();
var getcurrentdate=$('#hiddendate').val();
if(getcurrentmonth === month)
{
if(getcurrentdate == day )
{
document.write("<TD><a style='color:rgb(65, 255, 0)' href='#'>"+day+"</a></TD>")
}
else
{
document.write("<TD><a href='#'>"+day+"</a></TD>")
}
}
else
{
document.write("<TD><a href='#'>"+day+"<a></TD>")
}
day++
}
document.write("</TR><TR>")
// the first day of the next month
start_day=i
}
document.write("</TR></TABLE></DIV>")
}
// end hiding -->
// CAHNGE the below variable to the CURRENT YEAR
var d = new Date();
var n = d.getFullYear();
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var mm = month[d.getMonth()];
var dd=d.getDate();
today = mm+'/'+dd+'/'+n;
year=n
var leap = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
var add = 0;
if(leap == true ){
add = 1;
}
//alert(add);
$('#hiddenmonth').val(mm);
$('#hiddendate').val(dd);
// first day of the week of the new year
today= new Date("January 1, "+year)
start_day = today.getDay() + 1 // starts with 0
fill_table("January",31)
fill_table("February",28+add)
fill_table("March",31)
fill_table("April",30)
fill_table("May",31)
fill_table("June",30)
fill_table("July",31)
fill_table("August",31)
fill_table("September",30)
fill_table("October",31)
fill_table("November",30)
fill_table("December",31)
我使用了一个查询来从数据库中获取数据。我不知道如何进行下一步。我只想使用这个脚本来实现这一点,我不想使用jQuery。