There are two ways of doing this -
1) Add ORDER BY governorate, area_name to the sql query statement so that the rows in the result set are arranged together by first the governorate, then by the area_name within each governorate. When looping over the result set, you would detect a change in the governorate value, by using a variable to hold the 'last' value seen. When the value changes, you would close out any previous optiongroup and start a new optiongroup with the new value.
2) Pre-process (loop over) the result set and store the data into a multi-dimensional array using the governorate value as the main array's index. All the rows for any governorate value would be stored as a sub-array under the correct main index value. To produce the output, you would loop over the main array, the index would become the optiongroup value, then loop over each sub-array to produce the <option>....</option> list.
Method #2 results in the clearest code.
In any case, you should have an ORDER BY area_name as part of your sql query statement so that the output is in a determinate order.