samedi 5 mars 2016

looking for guidance on using and or statement to stop data being added to database

Hi there thanks to a member on here I managed to exclude the station name being entered if it is in the artist field now I am stuck using and or statement ..

Basically sometimes the track field also has station name in but is not limited to just the station name ....

Here is the code I have so far ...

if($artist != "stationname" ){

$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);
 };

 }

What I need some guidance on is how to stop entries being made if $artist = station name & or $track contains station name in the first 7 letters of $track any guidance on this would be appreciated as have spent hours trying to research this to no avail

Aucun commentaire:

Enregistrer un commentaire