require_once 'db_Select_gen.php'; // Generate a SELECT query that returns all rows from the 'users' table $sql = db_Select_gen('users'); // Execute the query and fetch all rows $result = $db->query($sql); $rows = $result->fetchAll(PDO::FETCH_ASSOC); // Print the results foreach ($rows as $row) { echo $row['username'] . ' ' . $row['email'] . '
'; }
require_once 'db_Select_gen.php'; // Generate a SELECT query that returns only active users from the 'users' table $sql = db_Select_gen('users', ['status' => 'active']); // Execute the query and fetch all rows $result = $db->query($sql); $rows = $result->fetchAll(PDO::FETCH_ASSOC); // Print the results foreach ($rows as $row) { echo $row['username'] . ' ' . $row['email'] . 'In this example, we use db_Select_gen to generate a SELECT query that returns only active users from the 'users' table. We pass an array of parameters to the function to specify which rows to select, and then execute and print the query results as before.
'; }