core php

i m selecting year and cohort and when i click search button it will display start date and end date from cohort calander.i want to dispaly the calander on start date and end date.what i do???plz replay me as son as…

[php]
calender.php

<?php include_once "include_file.php"; ?> Calendar <?php include_once "head.php"; ?> .cal th { background-color: #808080; } <?php if($_POST['coh_id'] != "") { $rs_coh_details = mysql_query("select * from CohartCalendar where Calendar_id = ".$_POST['coh_id']); $row_coh_details = mysql_fetch_array($rs_coh_details); } ?>
<?php include_once "logo.php" ?>

Training Center Administration

  <?php include_once "login_header.php"; ?>
</div>
<div class="line"></div>
<?php include_once "todays_date.php";?>

Calendar

Year: - -Select- - <?php for($i =-12;$i<=8;$i++) { ?> selected="selected" <?php } ?>><?php echo date('Y') + $i; ?> <?php } ?> Cohort: - -Select- - selected="selected" <?php } ?>>Spring selected="selected" <?php } ?>>Winter selected="selected" <?php } ?>>Fall selected="selected" <?php } ?>>Summer
  <?php 
if($_POST['submit'] != "" && $_POST['submit'] == "Search")
{
  	$Year = $_POST['Year'];
	$Cohort = $_POST['Cohort'];
		
	$query_calendar_data="SELECT Calendar_id,StartDate,EndDate,Holiday FROM cohartcalendar WHERE Year = '".$Year."' AND Cohort = '".$Cohort."'";
	$rs_calendar_data = mysql_query($query_calendar_data);
	$count_data = mysql_num_rows($rs_calendar_data);
	$Calendar_id = array();
	if($count_data >0){ ?>
<div >
  <table width="100%" border="1" cellpadding="2" cellspacing="2" style="border-collapse:collapse; ">
    <tr >
      <th scope="col">Option</th>
      <th  scope="col">Calendar_id</th>
      <th  scope="col">Start Date</th>
      <th scope="col">End Date</th>
      <th scope="col">Holiday</th>
     <!-- <th scope="col">Option</th>-->
    </tr>
    <?php
	 $sid = 000;

if($row_calendar_data = mysql_fetch_array($rs_calendar_data))
{ $sid++;
?>

<tr>
<td>
     
	   <a href="scheduled_edit.php"><input type="button" name="viewcalender" value="viewcalender" /></a>
	  
      </td> 
      <td><input class="inpt" style="width:120px;" type="text" name="StartDate" id="StartDate" value="<?php echo $row_calendar_data['Calendar_id']; ?>"/></td>
     <td><input class="inpt" style="width:120px;" type="text" name="StartDate" id="StartDate" value="<?php echo $row_calendar_data['StartDate']; ?>"/></td>
       <td class="rep_name"><input class="inpt" style="width:120px;" type="text" name="EndDate" id="EndDate" value="<?php echo $row_calendar_data['EndDate']; ?>"/></td>
       <td class="rep_name"><input class="inpt" style="width:120px;" type="text" name="Holiday" id="Holiday" value="<?php echo $row_calendar_data['Holiday'] ?>" /></td>
    <!--<td> <a href="datecalender.php" style="color:#FF0000;"> <input type="button" name="createdate" value="Create Date"  /> </a></td>-->
</tr> <?php "<td>"  ?>


 <?php }

?>

<?php }else{ ?>
No Records Found...
  </div>
   <?php 
if($_POST['coh_id'] != "")
	{ ?>
  <div class="cal">
    <table width="100%" border="1" cellpadding="2" cellspacing="2" style="border-collapse:collapse;">
      <tr>
        <th scope="col">Week #</th>
        <th scope="col">Monday</th>
        <th scope="col">Tuesday</th>
        <th scope="col">Wednesday</th>
        <th scope="col">Thursday</th>
        <th scope="col">Friday</th>
        <th scope="col">Saturday</th>
        <th scope="col">Sunday</th>
      </tr>
      <?php  
		$week_no =1;
		
		$start = $row_coh_details['StartDate'];
		$end = $row_coh_details['EndDate'];
		
		
		$init_date = strtotime($start);
		$dst_date = strtotime($end);
		
		$offset = $dst_date-$init_date;
		
		$dates = floor($offset/60/60/24) + 1;
		
		$fdate = explode("/",$row_coh_details['StartDate']);
		$ldate = $row_coh_details['EndDate'];
		
		$month = $fdate['0'];
		$date = $fdate['1'];
		$year = $fdate['2'];
		
		$start_date_day = date("l",mktime(0,0,0,$month,$date,$year));
		
		$DayName = strtolower($start_date_day);
					
		if ($DayName == "monday"){
			$colcnt = 1;
			$first_line = "";
		}
		else if ($DayName == "tuesday"){
			$colcnt = 2;
			$first_line = "<td></td>";
		}
		else if ($DayName == "wednesday"){
			$colcnt = 3;
			$first_line = "<td></td><td></td>";
		}
		else if ($DayName == "thursday")
		{
			$colcnt = 4;
			$first_line = "<td></td><td></td><td></td>";
		}
		else if ($DayName == "friday")
		{
			$colcnt = 5;
			$first_line = "<td></td><td></td><td></td><td></td>";
		}
		else  if ($DayName == "saturday")
		{
			$colcnt = 6;
			$first_line = "<td></td><td></td><td></td><td></td><td></td>";
		}
		else if ($DayName == "sunday")
		{
			$first_line = "<td></td><td></td><td></td><td></td><td></td><td class='num'></td>";
		}
		// calendar Start
		echo '<tr><td>'.$week_no.'</td>'.$first_line;
		for ($i = 0; $i < $dates; $i++)
		{
			$newdate = date("m/d/Y", mktime(12,0,0,date("m", strtotime($start)),
			(date("d", strtotime($start)) + $i), date("Y", strtotime($start))));
			
			$curent_date = explode("/",$newdate);
			
			$c_month = $curent_date['0'];
			$c_date = $curent_date['1'];
			$c_year = $curent_date['2'];
			
			$start_date_day = date("l",mktime(0,0,0,$c_month,$c_date,$c_year));
			
			$DayName = strtolower($start_date_day);
			
			if($DayName == "saturday" || $DayName == "sunday")
			{
				$class = "num";
			}else
			{
				$class = "";
			} 
				echo '<td class="'.$class.'">'; ?>
      <input type="text" name="<?php echo $newdate ?>" id="<?php echo $date_txt ?>" value="<?php echo $newdate; ?>" style="width:90px;" class="inpt hasDatepicker" />
      <?php
				echo '</td>';
			
			if($DayName == "sunday" && $newdate != $end)
			{
				$week_no++;
				echo '</tr><tr><td>'.$week_no.'</td>';
			}
		}
	
	?>
        </tr>
      
    </table>
  </div>
  <?php } ?>
<?php } }?>
  
</form>

</div>
[/php] [php] calander_save.php <?php include_once "include_file.php"; ?> <?php $year=$_POST['Year']; $Cohort = $_POST['Cohort']; $StartDate = $_POST['StartDate']; $Year = explode("/",$StartDate); $Year = $Year[2]; //$year=$_POST['Year']; $EndDate = $_POST['EndDate']; $Calendar_id = $_POST['Calendar_id']; if($Calendar_id != "") { $start = $_POST['StartDate']; $end = $_POST['EndDate']; $init_date = strtotime($start); $dst_date = strtotime($end); $offset = $dst_date-$init_date; $dates = floor($offset/60/60/24) + 1; $Holiday = array(); $Holiday_value = array(); for ($i = 0; $i < $dates; $i++) { $newdate = date("m/d/Y", mktime(12,0,0,date("m", strtotime($start)), (date("d", strtotime($start)) + $i), date("Y", strtotime($start)))); if($_POST[$newdate] != $newdate) { array_push($Holiday,$newdate); array_push($Holiday_value,$_POST[$newdate]); } } $Holiday = implode(",",$Holiday); $Holiday_value = implode(",",$Holiday_value); $query_coursecalendartbl = "UPDATE CohartCalendar set Cohort = '".$Cohort."',Year = '".$year."',StartDate = '".$StartDate."',EndDate ='".$EndDate."',EndDate ='".$EndDate."',Holiday ='".$Holiday."',Holiday_value ='".$Holiday_value."' where Calendar_id = '".$Calendar_id."'"; $rs_coursecalendartbl = mysql_query($query_coursecalendartbl); ?>

back to calender

<?php }else { $query_coursecalendartbl = "INSERT INTO CohartCalendar (Cohort,Year,StartDate,EndDate,Holiday) VALUES ('".$Cohort."','".$year."','".$StartDate."','".$EndDate."','".$Holiday."')"; $rs_coursecalendartbl = mysql_query($query_coursecalendartbl);

if($rs_coursecalendartbl){
$Calendar_id = mysql_insert_id();
}
?>

<?php } ?>

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service