What are the best practices for transitioning from mysql_* functions to mysqli in PHP?

When transitioning from mysql_* functions to mysqli in PHP, it is important to update your code to use the improved mysqli extension for better security and performance. To do this, you will need to replace all instances of mysql_* functions with their mysqli equivalents, such as mysqli_connect, mysqli_query, and mysqli_fetch_assoc.

// Before transitioning from mysql_* functions to mysqli
$conn = mysql_connect('localhost', 'username', 'password');
mysql_select_db('database_name', $conn);
$result = mysql_query('SELECT * FROM table_name');
while ($row = mysql_fetch_assoc($result)) {
    // Process data
}

// After transitioning to mysqli
$conn = mysqli_connect('localhost', 'username', 'password', 'database_name');
$result = mysqli_query($conn, 'SELECT * FROM table_name');
while ($row = mysqli_fetch_assoc($result)) {
    // Process data
}