Q: My question is if the prophet (Sallallahu Alayhi Wasallam) didn't know ilm-e-ghaib, then how did he know the following hadith.
Narrated by Hazrat Anas (Radiyallahu Anhu): Allah's Apostle (Sallallahu Alayhi Wasallam) ascended the (mountain) of Uhud with Abu Bakr and 'Uthman and it shook. Allah's Apostle (Sallallahu Alayhi Wasallam) said, "Be calm, O Uhud!" I think he stroked it with his foot and added, "There is none on you but a Prophet, a Siddiq and two martyrs." (The two martyrs were Hazrat Umar and Hazrat Uthman [Radiyallahu Anhuma]) (See Hadith No. 24). Hadith is in Bukhari.
How did he know that Hazrat Umar and Hazrat Uthman (Radiyallahu Anhuma) will be martyred?