I recently started learning PHP, and I don’t know everything about MySQL. Now I am writing code, performing the task I set myself for self-study. And now there is a problem in the code - you need to make the most optimal comparison of values or something else, so that duplicates are not recorded. I provide the code in text form and a screenshot for easy reading.
PS: I read about INSERT IGNORE but somehow its logic is not clear, please explain it clearly. Or suggest a better option. When I ran the code with if - (logic) - checking the link in the database (because the link is unique and if it is not in the database, it means you can write) the code uploaded 700+ records to the database (did not check for duplicates), but according to the idea, he had to fill in only 10 (since only 10 articles on one page).
Himself a piece of code:
/*запись данных в базу*/ $link_test=mysqli_query($bd, "SELECT * FROM `php_dns`.`habra_post`"); if(!$link_test){ $bd-> query("INSERT IGNORE INTO habra_post SET title='$title1', text_body='$text1', reg_date='$date1', full_text='$full_text', next_date='$date_nextd', link='$html_in'"); if($bd==false) { // echo "<br>Oll OK"; // } // else // { echo mysqli_error(); } }}} 
UNIQUEparameter can be assigned to this field. - lolbas