How can the issue of increasing $num_rows values with each reload be resolved in the PHP script?

The issue of increasing $num_rows values with each reload can be resolved by setting the $num_rows variable to 0 at the beginning of the script execution. This ensures that the count starts from 0 each time the script is loaded, preventing the accumulation of values.

$num_rows = 0;

// Rest of the PHP script