Look at the description of mysqli_fetch_assoc in the manual;
Returns an associative array of strings representing the fetched row in the result set, where each key in the array represents the name of one of the result set's columns or NULL if there are no more rows in resultset.
When you try to go over it a second time, you are already at the end, so it just returns NULL.
If you keep reading down that page you will see:
mysqli_data_seek() - Adjusts the result pointer to an arbitrary row in the result
… which will let you set the pointer back to the beginning (0
) so you and loop over it from the start.