अपने परिणामों को एक सरणी में सहेजें और फिर उस सरणी को दो बार लूप करें।
$pdo = new PDO('mysql:host=' . $host . ';dbname='.$database, $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare('SELECT * FROM mytable WHERE active = 1 ORDER BY name ASC');
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$stmt->execute();
$rows = $stmt->fetchAll();
foreach ($rows as $r) {
// first run
}
foreach ($rows as $r) {
// seconds run
}