2017-03-06 10:23
浏览 29


I have this query to count the number of forms that are submitted by a certain user

$sql="SELECT `ID` FROM `kform` WHERE `ID`='$ID'";                               
$result = $conn->query($sql);
if ($result->num_rows > 0) {
   while($row = $result->fetch_assoc()) {                                                                                                 

plus I have this php script that is basically check a certain date (which is included in each form) and prints valid if it is within this fiscal year

$endYear = 2017;
while($endYear <= 2025) {
    $end = $endYear.'/06/30';
    $endDate = DateTime::createFromFormat('Y/m/d', $end);
    $initDate = DateTime::createFromFormat('Y/m/d', $end);
    $initDate = $initDate->sub(new DateInterval('P1Y')) -> add(new DateInterval('P1D'));
    $ddb =  $row2['Date'];
    $dateFromDB = DateTime::createFromFormat('Y-m-d', $ddb);
    if ($dateFromDB >= $initDate && $dateFromDB <= $endDate) { 
        echo "valid
        echo "\tStartDate->\"".$initDate->format("Y-m-d")."\"
        echo "\tEndDate->\"".$endDate->format("Y-m-d")."\"
        echo "\tDateFromDatabase->\"".$dateFromDB->format("Y-m-d")."\"


Now what I was trying to do is to combine these two functions together, the idea behind that is to count only the forms that are in this fiscal year, any older forms should not be counted. I tried different ways to combine them but it gave me different errors every time, So is it even possible to do so?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题