Advertisement
meetsos

WP Get Results from DB in Array, and Search it for a Value

Mar 8th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. $fivesdrafts = $wpdb->get_results(
  2.     " SELECT `student_id` FROM `fu1sZ_arko_students` WHERE `canexam1` = 1 "
  3.     );
  4.  
  5.     $out = array();   //putting outside of the loop
  6.     foreach ( $fivesdrafts as $fivesdraft )
  7.         {
  8.         $jor = $fivesdraft->student_id;
  9.         array_push($out, $jor);
  10.         }
  11.         //$tow = implode(',', $out);
  12.         //echo $tow;
  13.  
  14.         // $people = array("Peter", "Joe", "Glenn", "Cleveland");
  15.         if (in_array("6", $out)) {
  16.         echo " <br/><br/>Match found";
  17.         }
  18.         else {
  19.         echo " <br/><br/>Match not found";
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement