$query = "SELECT * FROM user_table WHERE user_id = 123456"; $pdo = new PDO($dsn, $username, $password); $stmt = $pdo->prepare($query); $stmt->execute(); $user = $stmt->fetch(PDO::FETCH_ASSOC); // Use getFromDB() to extract user information $user_info = getFromDB($user['user_info_table'], 'user_id', $user['id']);
$query = "SELECT * FROM orders_table WHERE user_id = 123456"; $result = mysqli_query($conn, $query); $orders = array(); // Loop through results and add to orders array while ($row = mysqli_fetch_assoc($result)) { $orders[] = $row; } // Use getFromDB() to extract order information $order_info = getFromDB($orders, 'order_id', 789);In this example, we are again using `getFromDB()` to retrieve data from a separate table, but this time we are passing an array of results rather than using a prepared statement. We again pass columns to match and the order ID to the function. Package Library: MySQLi