I try to make notifications on several tables, the script itself basically works, gives out the data that is needed, but with one flaw.
The output comes from the friends and repost table, if both tables have the necessary record, then everything is fine, but if we say friends have it and the repost does not, then the friends record is displayed and with it the whole repost table and so with each id found.
Here is the request and output in the loop:
<?php $query = "SELECT `friends`.id AS friends_id, `repost`.id AS repost_id FROM `friends`,`repost` WHERE (`friends`.id_2 = '$_SESSION[id]' AND `friends`.id_1 <> '$_SESSION[id]' AND `friends`.obrabotan = '1') OR (`repost`.users = '$_SESSION[id]' AND `repost`.users2 <> '$_SESSION[id]' AND `repost`.status = '1')"; $sql_yvedom = mysql_query($query); while($row = mysql_fetch_array($sql_yvedom)){ echo $row["friends_id"].$row["repost_id"]; } I would be very grateful for the help, I do not know how to build a condition, so that if there is no repost , it would not output the entire table.