I have table with tv shows, in this table there are columns, one for start time and one for finishing time. I need to make that if you want to insert tv show that you cannot put 2 tv shows in same time, like in real television.
Table tvshows have columns: tvshow_id, name, description, startime, finishingtime. I want to insert info via form, but if there is already tvshow which overlaps another tv show, you cannot insert this in database, you need to change time.
My try of solving this problem:
$sql = "SELECT ...";
$result = mysqli_query ($link, $sql);
if(mysqli_num_rows($result) > 0) {
echo "Change datetime";
} else {
$sql = "INSERT ...";
}