Php 填写日期行中日期范围的日期

Php 填写日期行中日期范围的日期,php,mysql,Php,Mysql,两个问题: 当我单击“开始”时,如何在两个文本框中填写日期行中日期范围的所有日期 如何为所有进出行保留文本框 当我单击“提交”时,输入输出文本框必须保存到数据库: <?php session_start(); if (!$_SESSION['uname']) { header("Location:login.php"); } ?> <html><head><title>Attendance sheet</title> <l

两个问题:

  • 当我单击“开始”时,如何在两个文本框中填写日期行中日期范围的所有日期
  • 如何为所有进出行保留文本框
  • 当我单击“提交”时,输入输出文本框必须保存到数据库:

        <?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>
    
    
    签到表
    函数IsNumber(strFieldValue、size、strAlert)
    {
    对于(变量i=0;i“9”)
    {
    如果(strAlert!=“”)警报(strAlert)
    返回false;
    }
    }
    }
    返回true;
    }
    函数IsValidTime(timeStr){
    var timePat=/^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM | AM | PM | PM))?$/;
    var matchArray=timeStr.match(timePat);
    if(matchArray==null){
    警报(“时间格式无效”);
    返回false;
    }
    小时=匹配数组[1];
    分钟=匹配数组[2];
    第二个=匹配数组[4];
    ampm=匹配数组[6];
    if(second==“”){second=null;}
    如果(ampm==“”){ampm=null}
    如果(小时<0 | |小时>23){
    警报(“小时数必须介于1和12之间(军事时间为0和23)”;
    返回false;
    }
    如果(小时12&&m!=null){
    警报(“军事时间不能指定上午或下午。”);
    返回false;
    }
    若有(第59分钟){
    警报(“分钟必须介于0和59之间”);
    返回false;
    }
    if(秒!=null&(秒<0 | |秒>59)){
    警报(“秒数必须介于0和59之间”);
    返回false;
    }
    返回false;
    } 
    起始范围:
    终点范围:
    

    日期 在里面 出来 离开

    希望这有帮助

      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;  
    }  
    
    函数GetDays($sStartDate,$sEndDate){
    //首先,格式化提供的日期。
    //此函数最适合于YYYY-MM-DD
    //但是其他的约会方式也可以,谢谢
    //到strotime()。
    $sStartDate=gmdate(“Y-m-d”,strottime($sStartDate));
    $sEndDate=gmdate(“Y-m-d”,strotime($sEndDate));
    //以开始日期结束变量
    $aDays[]=$SSSTARTDATE;
    //设置“temp”变量sCurrentDate,并使用
    //开始日期-开始循环之前
    $sCurrentDate=$sStartDate;
    //而当前日期小于结束日期
    而($sCurrentDate<$sEndDate){
    //将日期添加到当前日期
    $sCurrentDate=gmdate(“Y-m-d”,strottime(+1天),strottime($sCurrentDate));
    //将新的一天添加到aDays数组中
    $aDays[]=$sCurrentDate;
    }  
    //循环完成后,返回
    //一系列的日子。
    返回$aDays;
    }  
    
    欢迎使用堆栈溢出!所以,这并不是一个“为我编写代码”的网站——如果这是你正在寻找的,你可能应该雇佣一位专家为你做这件事。如果您在处理该问题时遇到了特定的技术问题,请随意编辑相应的问题。