Good day, I am trying to create a form that will search for results in mysql DB and display the results using a loop. I have two options for searching, one using the ID and one using a string.The ID search works fine, as ID's are unique and one result is return which I can print out, but I am trying to adapt this to a function I can use for both, as the string should return a list results which will need to be looped through. The result is being returned as an object, and this is where I am struggling to get the loop to give a list of attributes and keys for each result, as it loops for each key=>Value fine, but need to know how to go through each object first, then the key=>Value.
In my class this is the find code i am using:
public static function find_by_qual_id($qual_id){
global $database;
$clean_qual_id = $database->escape_value($qual_id);
$result_array = static::find_by_sql("SELECT * FROM sdp WHERE qual_id='{$clean_qual_id}' LIMIT 1");
return !empty($result_array) ? array_shift($result_array) : false;
return $result_array;
}
On the page this is the loop (which does not work):
if(isset($qual_id)){
$qual_info = Qual_lookup::find_by_qual_id($search_qual_id);
if($qual_info != null){
echo "<h4>RESULTS FOUND FOR \"{$search_qual_id}\"</h4>";
echo "<div><form name=\"found_qual\"><table>";
foreach($qual_info as $qual){
foreach($qual as $key => $value){
echo "<tr><td>{$key} : </td><td">{$value}</td></tr>";
}
}
} else {
echo "No results found for \"{$search_qual_id}\"";
}
echo "</table></form></div>";
}