0
Use the following select to pick up items already seen:
$sql = $conn->query("SELECT * FROM views b, news a WHERE a.status = 'true' AND a.id = b.id_news AND b.ip = '$ip' ORDER BY a.id DESC LIMIT 6");
Where: $ip = $_SERVER['REMOTE_ADDR'];
.
Table structures:
views
id | id_news | ip
news
id | title | text | status
I intend to pick by a select all unseen news, IE, if I didn’t view it, don’t have my ip related to a news id.
I always feed table views when a user enters the news, there is inserted news id and user ip.
How can I make this such a select to pick only news not viewed? I hope that has been made clear.
Already tried using the operator <> or != ?
$sql = $conn->query("SELECT * FROM views b, news a WHERE a.status = 'true' AND a.id = b.id_news AND b.ip != '$ip' ORDER BY a.id DESC LIMIT 6");
– Valdeir Psr
Just use the above query select all the nodes that do not contain the user ip.
– Rafael Salomão
I used yes, however, it does not return anything, because it only has records of my ip in the table "views".
– Paulo Cavalcante
And as I said, the "views" table only records when someone accesses the news. I think a logic for this would be to check if my ip exists related to news, but in the query I do not know how to do this.
– Paulo Cavalcante