// Connect to database $conn = new mysqli($servername, $username, $password, $dbname); // Perform query $sql = "SELECT * FROM users"; $result = $conn->query($sql); // Convert result to array $rows = sql2array($result); // Loop through array foreach ($rows as $row) { echo $row['name'] . "
"; } // Close connection $conn->close();
// Connect to database $dbh = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass); // Prepare query and execute it $stmt = $dbh->prepare("SELECT * FROM users"); $stmt->execute(); // Convert result to array $rows = sql2array($stmt); // Loop through array foreach ($rows as $row) { echo $row['name'] . "It is difficult to determine the specific package library as the sql2array function is not a built-in PHP function. It is likely part of a third-party library or framework.
"; } // Close connection $dbh = null;