There are 8 numbers, so the median is the average of the 4th and 5th.
The sum of the 8 numbers is 3x+27; if the mean is 7, then the sum is 56. So
So the 6 numbers given are
2 3 3 4 6 9
and the two numbers we calculated are 9 2/3 and 19 1/3.
We know those numbers satisfy the condition that the mean is 7, because we used that fact to find the two numbers that were not given.
And the median of the set of all 8 numbers is 5, because the middle two are 4 and 6.
So the value of x that gives the data set a mean of 7 and a median of 5 is 29/3, or 9 2/3.