2012-02-24 11 views
0

二つの質問を埋める:私は、テキストボックスを維持するためにどのよう DATE行の日付範囲の日付

  • 2つのテキストボックスに日付範囲のDATE行を埋めるためにどのように、「GO」のすべての日付をクリックすると

    1. をすべてのINとOUT行の

    私はをクリックし、DBに保存でアウトテキストボックス必見 '提出':

    <?php 
    session_start(); 
    if (!$_SESSION['uname']) { 
    header("Location:login.php"); 
    } 
    ?> 
    <html><head><title>Attendance sheet</title> 
    <link rel="stylesheet" href="att_style.css" type="text/css" > 
    <script src="datetimepicker.js"> </script> 
    <script type="text/javascript"> 
    
    function IsNumber(strFieldValue, size, strAlert) 
    { 
    for (var i=0; i < size; i++) 
    {  
    if(strFieldValue.charAt(i)!="") 
    {  
    if(strFieldValue.charAt(i) < "0" || strFieldValue.charAt(i) > "9") 
    { 
    if(strAlert != "")alert(strAlert) 
    return false; 
    } 
    } 
    } 
    return true; 
    } 
    
    function IsValidTime(timeStr) { 
    var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/; 
    
    var matchArray = timeStr.match(timePat); 
    if (matchArray == null) { 
    alert("Time is not in a valid format."); 
    return false; 
    } 
    hour = matchArray[1]; 
    minute = matchArray[2]; 
    second = matchArray[4]; 
    ampm = matchArray[6]; 
    
    if (second=="") { second = null; } 
    if (ampm=="") { ampm = null } 
    
    if (hour < 0 || hour > 23) { 
    alert("Hour must be between 1 and 12. (or 0 and 23 for military time)"); 
    return false; 
    } 
    if (hour <= 12 && ampm == null) { 
    if (confirm("Please indicate which time format you are using. OK = Standard Time, CANCEL = Military Time"))  { 
    alert("You must specify AM or PM."); 
    return false; 
    } 
    } 
    if (hour > 12 && ampm != null) { 
    alert("You can't specify AM or PM for military time."); 
    return false; 
    } 
    if (minute<0 || minute > 59) { 
    alert ("Minute must be between 0 and 59."); 
    return false; 
    } 
    if (second != null && (second < 0 || second > 59)) { 
    alert ("Second must be between 0 and 59."); 
    return false; 
    } 
    return false; 
    } 
    </script> 
    </head> 
    <body> 
    <form name="timeform" method="post" action="" > 
    
    <label for="range_start">Start range:</label> <input name="from" id="frm_date" type="text" > 
    
    <a href="javascript:NewCal('frm_date','ddmmyyyy')"><img src="cal.gif" alt="pick a date"></a> 
    &nbsp;&nbsp;&nbsp;&nbsp; 
    
    <label for="range_end">End range:</label> <input name="to" id="dpk" type="text" > 
    
    <a href="javascript:NewCal('dpk','ddmmyyyy')"><img src="cal.gif" alt="pick a date"></a> 
    &nbsp;&nbsp; 
    
    <input name="date_but" type="submit" value="Go"> 
    <a style="float:right" href="logout.php">Logout</a> 
    <br/><br/> 
    <?php 
    if (isset($_REQUEST['date_but'])) { 
    $fromDate = $_REQUEST['from']; 
    $toDate = $_REQUEST['to']; 
    
    $dateMonthYearArr = array(); 
    $fromDateTS = strtotime($fromDate); 
    $toDateTS = strtotime($toDate); 
    
    for ($currentDateTS = $fromDateTS; $currentDateTS <= $toDateTS; $currentDateTS += (60 * 60 * 24)) { 
    
    $currentDateStr = date("d-M-Y",$currentDateTS); 
    $dateMonthYearArr[] = $currentDateStr; 
    
    } 
    
    echo "No of days: " . count($dateMonthYearArr); 
    ?> 
    <table border="1" cellspacing="0" cellpadding="5" align="center"> 
    <tr> 
    <th scope="row">DATE</th> 
    <div class="dat_row"> 
    <td><?php print_r($dateMonthYearArr[0]); ?></td> 
    <td><?php echo $dateMonthYearArr[1]; ?></td> 
    <td><?php echo $dateMonthYearArr[2]; ?></td> 
    <td><?php echo $dateMonthYearArr[3]; ?></td>   
    </div> 
    
    </tr> 
    <tr> 
    <th scope="row">IN</th> 
    <td><input name="time" type="text" ></td> 
    <td><input name="r2_in" type="text" ></td> 
    <td><input name="r2_in" type="text" ></td> 
    </tr> 
    <tr> 
    <th scope="row">OUT</th> 
    <td><input name="time" type="text"></td> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    </tr> 
    <tr> 
    <th scope="row">Leave</th> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    </tr> 
    </table><br/><br/> 
    <input name="submit" type="submit" onClick="IsValidTime(document.timeform.time.value);" value="Submit"> 
    <?php 
    
    } ?> 
    </form> 
    </body> 
    </html> 
    
  • +0

    ようこそスタックオーバーフロー!それはあなたが探しているものなら、おそらくあなたのためにそれをする専門家を雇うべきです。問題に取り組んでいる*特定の*技術的な質問がある場合は、それに応じて質問を自由に編集してください。 –

    答えて

    0

    希望はこのことができます

    function GetDays($sStartDate, $sEndDate){ 
        // Firstly, format the provided dates. 
        // This function works best with YYYY-MM-DD 
        // but other date formats will work thanks 
        // to strtotime(). 
        $sStartDate = gmdate("Y-m-d", strtotime($sStartDate)); 
        $sEndDate = gmdate("Y-m-d", strtotime($sEndDate)); 
    
        // Start the variable off with the start date 
        $aDays[] = $sStartDate; 
    
        // Set a 'temp' variable, sCurrentDate, with 
        // the start date - before beginning the loop 
        $sCurrentDate = $sStartDate; 
    
        // While the current date is less than the end date 
        while($sCurrentDate < $sEndDate){ 
        // Add a day to the current date 
        $sCurrentDate = gmdate("Y-m-d", strtotime("+1 day", strtotime($sCurrentDate))); 
    
        // Add this new day to the aDays array 
        $aDays[] = $sCurrentDate; 
        } 
    
        // Once the loop has finished, return the 
        // array of days. 
        return $aDays; 
    }