1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[SQL] PHP -SQL Select Where Greater Than Minute And Hour

Discussão em 'Outras Linguagens' iniciado por Stack, Setembro 27, 2021.

  1. Stack

    Stack Membro Participativo

    I wanna get specific shift time from my database but this scripts return "0 results";

    This is my database

    id | shift_title | start_time | end_time |
    ------------------------------------------
    1 | shift1 | 00:00 | 08:30 |
    2 | shift2 | 08:30 | 12:00 |
    3 | shift3 | 12:00 | 19:30 |
    4 | shift4 | 19:00 | 00:00 |



    and this is my php script

    include 'config.php';
    $create_time = date('H:i');

    $sql = "SELECT * FROM shift_times WHERE start_time <= '$create_time' AND end_time > '$create_time'";
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
    echo $row["shift_title"];
    }
    } else {
    echo "0 results";
    }
    $conn->close();

    Continue reading...

Compartilhe esta Página