이 코드를 사용하고 대사관 휴일 : 데이터베이스에서 대사관의 개방 시간을 소요하고 대사관은 현재 열려 있는지 여부를 결정 PHP 개방 시간 및
$rawsql = "SELECT
*
FROM
_erc_foffices n
INNER JOIN
_erc_openings o ON n.id = o.branch_id AND o.dotw = DAYOFWEEK(CURRENT_DATE())
INNER JOIN
_erc_openings_times t ON o.id = t.opening_id
WHERE
(
UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) BETWEEN UNIX_TIMESTAMP(CONCAT(CURRENT_DATE(), ' ', t.open)) AND UNIX_TIMESTAMP(CONCAT(CURRENT_DATE(), ' ', t.close))
)
AND
(
n.id = %d
)
;";
$sql = sprintf($rawsql, mysql_real_escape_string($id));
$result = mysql_query($sql);
/*These if & while statements decide whether or not the information should be displayed. If no results are returned from the query above then an alternative message is shown.*/
if(mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<div class='address'><p>" . $row["title"] . "<br/>";
echo $row["address_1"] . "<br/> " . $row["address_2"] . "<br/> " . $row["address_3"] . "<br/> " . $row["address_4"] . "<br/> " . $row["address_5"] . "</p>";
echo "<div class='buttons'><img src='http://localhost/erc/images/texttouser_button.png'/><br/><a href='" . $row["url"] . "' target='blank'><img src='http://localhost/erc/images/website_button.png'/></a></div></div>";
echo "<div class='email'>" . $row["email"] . "</div>";
$extra_notes = $row["extra"];
}
} else {
$embassy_closed = mysql_query("SELECT * FROM _erc_foffices WHERE id = '$embassy_id'");
while($row = mysql_fetch_array($embassy_closed))
{
echo "<div class='address'><p>" . $row["title"] . "<br/>";
echo $row["address_1"] . "<br/> " . $row["address_2"] . "<br/> " . $row["address_3"] . "<br/> " . $row["address_4"] . "<br/> " . $row["address_5"] . " <font color='red'>The embassy is closed.</font></p>";
echo "<div class='buttons'><img src='http://localhost/erc/images/texttouser_button.png'/><br/><a href='" . $row["url"] . "' target='blank'><img src='http://localhost/erc/images/website_button.png'/></a></div></div>";
echo "<div class='email'>" . $row["email"] . "</div>";
$extra_notes = $row["extra"];
}
}
. 그렇지 않은 경우 '대사관이 폐쇄되었습니다'라는 메시지가 표시됩니다. 지금은 공휴일에 추가해야합니다, 그래서 다음과 같이 할 수있는 쿼리를 변경 한 :
$rawsql = "SELECT
*
FROM
_erc_foffices n
INNER JOIN
_erc_openings o ON n.id = o.branch_id AND o.dotw = DAYOFWEEK(CURRENT_DATE())
INNER JOIN
_erc_openings_times t ON o.id = t.opening_id
LEFT JOIN
_erc_holidays h ON h.branch_id = n.id
WHERE
(
UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) BETWEEN UNIX_TIMESTAMP(CONCAT(CURRENT_DATE(), ' ', t.open)) AND UNIX_TIMESTAMP(CONCAT(CURRENT_DATE(), ' ', t.close))
)
AND
(
n.id = %d
)
AND
(
UNIX_TIMESTAMP(CURRENT_TIMESTAMP())
NOT BETWEEN UNIX_TIMESTAMP(h.begins_at) AND UNIX_TIMESTAMP(h.ends_at)
)
;";
을하지만 이것은 단지 두 번 주소/이메일 등을 출력합니다.
누군가 내가 잘못하고있는 것을 지적 할 수 있습니까? 어떤 도움
편집에 대한
감사합니다 : 난 그냥 2 쿼리를 사용하는 경우/다른 루프, 지금이 문제를 해결했습니다.
안녕하세요, 저희 직원이 대사관 웹 사이트를 직접 방문하여 데이터를 수동으로 수집하고 있습니다. –