<?php
require_once __DIR__ . '/../includes/bootstrap.php';
auth_require_admin();
$rows = $pdo->query("
  SELECT u.id, u.email, u.kyc_submitted_at,
         (SELECT COUNT(*) FROM kyc_documents d WHERE d.user_id=u.id) AS docs
  FROM users u WHERE u.kyc_status='pending' ORDER BY u.kyc_submitted_at ASC
")->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $r){
  echo "<div>{$r['email']} ({$r['docs']} docs) ".
       "<a href='/admin/kyc_review.php?uid={$r['id']}'>Review</a></div>";
}
