Are there any alternative methods to mysql_query() and mysql_result() functions for fetching and storing SQL results in PHP?

The mysql_query() and mysql_result() functions are deprecated in PHP and should not be used in new code due to security vulnerabilities and lack of support in newer PHP versions. Instead, developers should use mysqli or PDO extensions to interact with a MySQL database in a more secure and modern way.

// Using mysqli extension to fetch and store SQL results
$mysqli = new mysqli("localhost", "username", "password", "database");

$result = $mysqli->query("SELECT * FROM table");

while ($row = $result->fetch_assoc()) {
    // Process each row here
}

$result->free();
$mysqli->close();