daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest May 19th, 2017 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. FUNCTION getUniquePosts($num = 10, $db) {
  2. $postarr = array();
  3. $skip = array();
  4. FOR($i = 0; $i < $num; $i++) {
  5.     $sql = "SELECT p.ID as ID, p.Date as Date, p.Thread as Thread, t.Subject as Subject from unb_posts AS p, unb_threads AS t where (p.Thread=t.ID)";
  6.     IF(COUNT($skip)) {
  7.         foreach($skip AS $tid) {
  8.             $sql .= "AND (p.Thread != ".$tid.") ";
  9.         }
  10.     }
  11.     $sql .=" ORDER BY p.Date DESC limit 1";
  12.     // okay, do query
  13.     $res = mysql_query($sql, $db);
  14.     $row = mysql_fetch_assoc($res);
  15.     $postarr[] = $row;
  16.     $skip[] = $row['Thread'];
  17. }
  18. RETURN $postarr;
  19. }
RAW Paste Data
Top