コード例 #1
0
}
if (isset($_GET['key'])) {
    $key = "77da1177af80396ea90acbd644f4b08164fe89764fa777416ec8ddc621ae2136";
    if ($key == hash("sha256", $_GET['key'])) {
        $i = 0;
        $today = new DateTime();
        $year = $today->format('Y');
        $sql = "SELECT male.Name AS M_NAME, date_format(male.DOB,'" . $year . "-%m-%d') AS M_DOB FROM male ORDER BY date_format(male.DOB,'%m-%d-%Y')";
        if ($result = mysqli_query($connection, $sql)) {
            while ($row = mysqli_fetch_assoc($result)) {
                create_date_array($row['M_DOB'], $row['M_NAME']);
            }
        }
        //$i=0;
        $sql = "SELECT female.Name AS F_NAME, date_format(female.DOB,'" . $year . "-%m-%d') AS F_DOB FROM female ORDER BY date_format(female.DOB,'%m-%d-%Y')";
        if ($result = mysqli_query($connection, $sql)) {
            while ($row = mysqli_fetch_assoc($result)) {
                create_date_array($row['F_DOB'], $row['F_NAME']);
            }
        }
        $sql = "SELECT male.Name as M_NAME, female.Name AS F_NAME, date_format(common.DOM,'" . $year . "-%m-%d') AS DOM FROM male,female,common WHERE common.id = male.id AND female.id=male.spouse_id ORDER BY date_format(common.DOM,'%m-%d-%Y')";
        if ($result = mysqli_query($connection, $sql)) {
            while ($row = mysqli_fetch_assoc($result)) {
                $data = $row['M_NAME'] . " and " . $row['F_NAME'] . " (Anniversary)";
                create_date_array($row['DOM'], $data);
            }
        }
        mysqli_close($connection);
        echo json_encode($bna);
    }
}
コード例 #2
0
            while ($row = mysqli_fetch_assoc($result)) {
                if ($i == 0) {
                    $bna[$i] = create_date_array($row['M_DOB'], $row['M_NAME']);
                    $i++;
                } elseif ($bna[$i - 1]['date'] == $row['M_DOB']) {
                    array_push($bna[$i - 1]['list'], $row['M_NAME']);
                } else {
                    $bna[$i] = create_date_array($row['M_DOB'], $row['M_NAME']);
                    $i++;
                }
            }
        }
        $sql = "SELECT female.Name AS F_NAME, date_format(female.DOB,'" . $year . "-%m-%d') AS F_DOB FROM female ORDER BY date_format(female.DOB,'%m-%d-%Y')";
        if ($result = mysqli_query($connection, $sql)) {
            while ($row = mysqli_fetch_assoc($result)) {
                $added = false;
                foreach ($bna as $key => $value) {
                    if ($value['date'] == $row['F_DOB']) {
                        array_push($value['list'], $row['F_NAME']);
                        $added = true;
                        break;
                    }
                }
                if (!$added) {
                    $bna[$i] = create_date_array($row['F_DOB'], $row['F_NAME']);
                }
            }
        }
        echo json_encode($bna);
    }
}