2016-04-30 1 views
0

私はいくつかのコードで厄介な問題を抱えています。私はこの男から)(私はWOWAwesomeのユーチューブチャンネルで見つかったカレンダーのコードを使用して、動的に機能draw_calenderを使用してカレンダーを描くことができるようにいくつかのPHPを使用している:https://davidwalsh.name/php-calendarPHP:whileループ要素が張り付いている

これは各カレンダーを生成するための私のコードです:

これが正しくフォーマットされていない場合は、ここで
<?php 

    $sql2 = "SELECT timeStart, timeEnd, dateFor, languageTaught, status FROM tutorslots WHERE tutorid='$tutorid'"; 
     include('calendar/calendar.php'); 
      $result2 = mysqli_query($conn,$sql2); 
       if (!$result2) { 
       echo 'MySQL Error: ' . mysqli_error(); 
       exit; 
       } 

      while ($row2 = mysqli_fetch_assoc($result2)) { 

      $timeStart = $row2["timeStart"]; 
      $timeEnd = $row2["timeEnd"]; 
      $date = $row2["dateFor"]; 
      $languageTaught = $row2["languageTaught"]; 
      $status = $row2["status"]; 

      $dateElements = explode('-', $date); 
      $year1 = $dateElements[0]; 
      $mo = $dateElements[1]; 
      $day1 = $dateElements[2]; 
      $lTaught1 = $languageTaught; 

      echo "<h1>".$date."</h1>"; 
      echo "<br>";  
      echo draw_calendar($mo,$year1,$day1,$lTaught1); 


      } 
    ?> 

申し訳calendar.phpページ

<html> 
<head> 
    <meta name="viewport" content="width=device=width, initial-scale=1"> 
    <link rel="stylesheet" href="style.css" type="text/css"> 
</head> 
<body> 

    <?php 
    if(!function_exists('draw_calendar')){ 
     function draw_calendar($month,$year,$day1,$lTaught1){ 

      switch($lTaught1){ 
        case "eng": 
         $language = "English"; 
         break; 
        case "oth": 
         $language = "Other"; 
         break; 
        case "chi": 
         $language = "Chinese"; 
         break; 
       }; 
      /* draw table */ 
      $calendar = '<div id="calendar-wrapper">'; 

      /* table headings */ 

      $calendar.= '<div id="weekday"><ul> 
       <li>Sunday</li> 
       <li>Moday</li> 
       <li>Tuesday</li> 
       <li>Wednesday</li> 
       <li>Thursday</li> 
       <li>Friday</li> 
       <li>Saturday</li> 
      </ul></div><div id="calendar">'; 

      /* days and weeks vars now ... */ 
      $running_day = date('w',mktime(0,0,0,$month,1,$year)); 
      $days_in_month = date('t',mktime(0,0,0,$month,1,$year)); 
      $days_in_this_week = 1; 
      $day_counter = 0; 
      $dates_array = array(); 

      /* row for week one */ 
      $calendar.= '<ul class="days">'; 

      /* print "blank" days until the first of the current week */ 
      for($x = 0; $x < $running_day; $x++): 
       $calendar.= '<li class="day other-month"></li>'; 
       $days_in_this_week++; 
      endfor; 

      /* keep going with days.... */ 
      for($list_day = 1; $list_day <= $days_in_month; $list_day++): 

        /* add in the day number */ 
        if($day1 == $list_day && $status="available"){ 
         $calendar.= '<li class="day">'; 

         $calendar .= '<div class="date">'.$list_day.'</div>'; 
         $calendar .= '<div class="event">'.$language.'</div>'; 
        } else { 
         $calendar.= '<li class="day">'; 
        $calendar.= '<div class="date">'.$list_day.'</div>'; 
        } 


       $calendar.= '</li>'; 
       if($running_day == 6): 
        $calendar.= '</ul>'; 
        if(($day_counter+1) != $days_in_month): 
         $calendar.= '<ul class="days">'; 
        endif; 
        $running_day = -1; 
        $days_in_this_week = 0; 
       endif; 
       $days_in_this_week++; $running_day++; $day_counter++; 
      endfor; 

      /* finish the rest of the days in the week */ 
      if($days_in_this_week < 8): 
       for($x = 1; $x <= (8 - $days_in_this_week); $x++): 
        $calendar.= '<li class="day other-month"></li>'; 
       endfor; 
      endif; 

      /* final row */ 
      $calendar.= '</ul>'; 

      /* end the table */ 
      $calendar.= '</div>'; 

      /* all done, return result */ 
      return $calendar; 

     } 
    } 



?> 


</body> 
</html> 

です。何が起きているのですか:http://imgur.com/J6kusnR私の質問はなぜ新しい行にはないのですか? jQueryのタブ(3つのカレンダーが生成されています)を追加しようとすると、それらのタブはすべて分割されていましたが、最初のタブdivに移動しました。

何か助けが巨大になる、事前に感謝!

答えて

0

これはコメントに含まれていると思いますが、50人の担当者がいるまではできません。

あなたの日付があなたのカレンダーの右側に浮かんでいるのは、draw_calendar()呼び出しの中に描画されていないからです。 #calendar-wrapperタグの内側に置いておきます。

jQueryのタブにカレンダーを追加するには、誰かが意見を述べるために使用したコードを提供する必要があります。

+0

YEPありがとう。どういうわけか病院にあなたに代わってください! – Dooba

関連する問題