1

In my notification current the day I used a view column in update table which update view = 1 if viewed else view = 0 . But in case for make notification for many user for a particular update, its cannot work if a user viewed first.

So I create that new table named updateview to stored post_id & user_id that viewed. (here post_id is update table's id)

My update table where all update stored and a updateview table which stored update table id and user ID if user viewed any update. That means updateview table insert id & userID when user view any post from notification drop-down menu.

How how to create SELECT Statement for select all update table id that was not in updateview post_id.

Here is my update table: [no foreign key, id(AI)]

id | work_id | from_id | to_id | date

updateview table: [no foreign key, id(AI)]

id | post_id | user_id

Here below my 3rd query select all id from update table that related with user follower, fan page. Here I want reduce that id which find in updateview table.

Query 1: Get all follower id and return: $f2_ids[] = $row['follow'];

Query 2: Get all liked fan page id and return : $pg_ids[] = $row['userid'];

Query 3:

foreach((array)$f2_ids as $indx => $value) {

$myid = $session->id;

    $g = mysqli_query($db,"SELECT id FROM update WHERE 
        `to_id`='".$myid."' AND `from_id`='".$f2_ids[$indx]."' OR
        `to_id`='".$f2_ids[$indx]."' AND `from_id`='".$myid."' OR
        `to_id`='".$pg_ids[$indx]."' OR 
        `from_id`='".$pg_ids[$indx]."' AND `to_id`='0' GROUP BY id") or
        die(mysqli_error($db));
        $count = mysqli_num_rows($g); 
    //etc... do something....
}
koc
  • 955
  • 8
  • 26

1 Answers1

0

Try count() Function

$count = count($g); 
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85