What potential issue could arise when using the PHP function mysql_fetch_array() in a loop?

When using the mysql_fetch_array() function in a loop, it is important to check if there are any more rows left in the result set before fetching the next row. If this check is not performed, it could lead to an infinite loop or errors due to trying to fetch rows that do not exist. To solve this issue, you can use the mysql_num_rows() function to check if there are any more rows left to fetch.

$result = mysql_query("SELECT * FROM table");

if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_array($result)) {
        // Process the row data here
    }
} else {
    echo "No rows found";
}