This is my current code:
$wonAwards = $altdb->get_var("SELECT achievement_id
FROM user_1
WHERE isTold='false'");
Currently, $wonAwards is set equal to the first result of the sql query. Is it possible to set $wonAwards equal to an array of all the results of the query?
////////////////// Full Function
function the_header_function(){ //called when wordpress header is loaded
if (is_user_logged_in()){ //checks if user is logged in
global $altdb; //wp global database object
$user_info = wp_get_current_user();
$wonAwards = $altdb->query("SELECT achievement_id FROM user_".$user_info->ID." WHERE isTold='false'"); //query
if(is_array($wonAwards)) $hello='true';
if(!is_array($wonAwards)) $hello='false';
if($wonAwards != ''){
echo "<script>jQuery(document).ready( function(){alert('".$hello."');});</script>";
}
}
}
As for checking what the result of my query was, I simply changed this:
echo "<script>jQuery(document).ready( function(){alert('".$hello."');});</script>";
to this:
echo "<script>jQuery(document).ready( function(){alert('".$wonAwards."');});</script>";
Well, according to the Documentation Here,
get_varwill give you a single result, andquerywill give you the number of results.What you really wants (getting all results) can be achieved by the
get_resultsmethod, so you should write:Try it and tell us if it works, hope that’s helpful.