在一天中的特定时间将数据插入MySQL

Basically I am trying to figure out how to insert data into mysql using php. I need to insert data at several different times of the day automatically everyday. When a button is click I basically need if time is less then < 9:45 then insert '1' else if time is > 9:45 insert '2' else if time is > 12:20 insert '3' and so on. I've tried a bunch of different ways but none of them seem to work without changing my code completely.

<?php

date_default_timezone_set("America/New_York");
define('DB_NAME', 'name');
define('DB_USER', 'userr');
define('DB_PASSWORD', 'passwd');
define('DB_HOST', 'localhost');

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!$link) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db(DB_NAME, $link);

if (!db_selected) {
    die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}

$value = $_POST['period'];
$value2 = $_POST['name'];
$date = date('m/d/Y h:i:s', time());

$sql = "INSERT INTO flvs (timestamp, period, name) VALUES ('$date','$value', '$value2')";

if (!mysql_query($sql)) {
    die('Error: ' . mysql_error());
}

If you want to check the time when the button in click you can get the server time (date and time functions) and check it and save. But if you want do the jobs automatically every hour or day or month you can use cronjobs.

Read these, on how to create a cronjob or cPanel cronjobs.

INSERT INTO flvs (timestamp, period, name) 
select '$date', 
        case when time(now()) < '09:45:00' then '1' 
             when time(now()) > '12:20:00' then '3' 
             when time(now()) > '09:45:00' then '2' 
             else 0
        end,
       '$value2'