Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 1.64 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Get array of all matches in mysql query?
  2. $wonAwards = $altdb->get_var("SELECT achievement_id
  3.                                 FROM user_1
  4.                                WHERE isTold='false'");
  5.        
  6. function the_header_function(){ //called when wordpress header is loaded
  7.     if (is_user_logged_in()){ //checks if user is logged in
  8.         global $altdb;  //wp global database object
  9.         $user_info = wp_get_current_user();
  10.         $wonAwards = $altdb->query("SELECT achievement_id FROM user_".$user_info->ID." WHERE isTold='false'"); //query
  11.         if(is_array($wonAwards)) $hello='true';
  12.         if(!is_array($wonAwards)) $hello='false';
  13.         if($wonAwards != ''){
  14.             echo "<script>jQuery(document).ready( function(){alert('".$hello."');});</script>";
  15.         }
  16.     }
  17. }
  18.        
  19. echo "<script>jQuery(document).ready( function(){alert('".$hello."');});</script>";
  20.        
  21. echo "<script>jQuery(document).ready( function(){alert('".$wonAwards."');});</script>";
  22.        
  23. $wonAwards = $altdb->get_results("SELECT achievement_id
  24.                                 FROM user_1
  25.                                WHERE isTold='false'");
  26.        
  27. $wonAwards = $altdb->get_var("SELECT achievement_id
  28.                             FROM user_1
  29.                            WHERE isTold
  30.                            IN ('false', 'true', 'another_value', 'some_other')");
  31.        
  32. $array = array("data1", "data2", "data3");
  33. $implode = implode("', '", $array);
  34.  
  35. //Output or $implode
  36. data1', 'data2', 'data3
  37.  
  38. //apply on query
  39. $wonAwards = $altdb->get_var("SELECT achievement_id
  40.                             FROM user_1
  41.                            WHERE isTold
  42.                            IN ('$implode')");