I am building a database of latest tracks played on a station and I do not want entries with the station name being added to the database.
I know that I will need to use if else and else if because of what I want to do as I am already checking if entry exists with if and else so am just looking for some pointers on how to stop entries being added if radio name is in the $trackartist field
I know I need to do something along the lines of if $trackartist = station name do nothing else check if entry exists else if do the insert.
Here is the code I am using to fill the rows.
include('config.php');
$str = file_get_contents('xxxxxxxx.xxx');
$json = json_decode($str, true);
$artist = $json['now_playing']['artist'];
$track = $json['now_playing']['track'];
$cover = $json['cover'];
$check = mysqli_query($mysqli,"select * from recent where trackartist='$artist' and tracktitle='$track' and coverurl='$cover'");
$checkrows=mysqli_num_rows($check);
if($checkrows>0) {
echo "track exists";
} else {
$sql = "INSERT IGNORE INTO recent (trackartist, tracktitle, coverurl)
VALUES ('$artist', '$track', '$cover')";
$result = mysqli_query($mysqli, $sql) or die('Error querying database.');
mysqli_close($mysqli);
};