I want to use $wpdb query instead of mysqli for my wordpress table.
The wordpress table in question as follows : wp_example
+----+---------------------+------+
| id | name | age |
+----+---------------------+------+
| 1 | Sandy Smith | 21 |
| 2 | John Doe | 22 |
| 3 | Tim Robbins | 28 |
| 4 | John Reese | 29 |
| 5 | Harold Finch | 20 |
+----+---------------------+------+
The mysqli query which I would like to be in $wpdb:
<?php
// Make a MySQL Connection
$query = "SELECT * FROM wp_example";
$result = $mysqli->query($query);
$row = $result->fetch_array(MYSQLI_ASSOC);
printf ("%s (%s)\n", $row["name"], $row["age"]);
/* close connection */
?>
Reference 1
Reference 2
I started out to try something on my own but got stuck.
global $wpdb;
$query = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_example", ARRAY_A));
would love to have further guidance.