The sending down of the Quran began on Laylat al-Qadr in Ramadan, but fasting was not enjoined until the second year AH
Question

Was the Quran sent down over twenty-three years or on Laylat al-Qadr {Indeed, We sent the Quran down during the Night of Decree}, as Laylat al-Qadr is in Ramadan? Muhammad (blessings and peace of Allah be upon him) fasted for 9 years, meaning he fasted 9 times. So how could the Quran be revealed over twenty-three years in Ramadan, when the Prophet (blessings and peace of Allah be upon him) fasted in Ramadan for nine years, because fasting was not enjoined from the time the Prophet (blessings and peace of Allah be upon him) became a prophet, and because his prophethood lasted for 23 years. In other words, he fasted in the last nine years, but the Quran was only revealed in Ramadan, so how come the Quran was revealed over twenty-three years in Ramadan?
Praise be to Allah.The Quran was revealed to the Prophet (blessings and peace of Allah be upon him) at the beginning of his mission, and the first revelation came in the month of Ramadan, on Laylat al-Qadr, as Allah, may He be exalted, says (interpretation of the meaning):
{Indeed, We sent the Quran down during the Night of Decree} [al-Qadr 97:1]
{Ha, Meem.
By the clear Book. 
Indeed, We sent it down during a blessed night. Indeed, We were to warn [mankind]} [ad-Dukhaan 44:1-3].
Then it continued to be sent down piecemeal until shortly before the death of the Prophet (blessings and peace of Allah be upon him), as Allah says (interpretation of the meaning):
{And [it is] a Quran which We have separated [by intervals] that you might recite it to the people over a prolonged period. And We have sent it down progressively} [al-Isra’ 17:106].
Fasting was not enjoined at that time; rather fasting was not enjoined until the second year AH – in other words, fifteen years after the revelation of the Quran began.
So there is no connection between the sending down of the Quran and fasting.
Rather the connection is between the Quran and the month of Ramadan and Laylat al-Qadr. The month of Ramadan was known before the Prophet's mission began and afterwards, as were all the other [Arabic] months.
There is no connection between Laylat al-Qadr and fasting, because Laylat al-Qadr is a night in the month of Ramadan, which was known before fasting was enjoined.
What appears to be the case is that this is the reason for your question, which is that you think that there is a connection between Laylat al-Qadr and fasting, and you have not borne in mind the fact that this night and the month in which it occurs were known even before fasting was enjoined.
To sum up:
The sending down of the Quran began in Ramadan of the first year of the Prophet’s mission, and continued for 23 years.
With regard to fasting, it was enjoined approximately fifteen years after the Prophet’s mission began – that is, after the first words of the Quran were revealed – and the Prophet (blessings and peace of Allah be upon him) fasted nine Ramadans; during these years, the Quran continued to be revealed.
Al-Qurtubi (may Allah have mercy on him) said: The words of Allah, may He be exalted, {Indeed, We sent it down} refer to the Quran. It is not mentioned by name in this soorah because what is being referred to is clear, and the entire Quran is like a single soorah. Allah says (interpretation of the meaning):
{The month of Ramadhan [is that] in which was revealed the Quran} [al-Baqarah 2:185]
{Ha, Meem.
By the clear Book. 
Indeed, We sent it down during a blessed night} [ad-Dukhaan 44:1-3]
– what is meant is on Laylat al-Qadr.
Ash-Sha‘bi said: What is meant is: We began to send it down on Laylat al-Qadr.
And it was said: Rather Jibreel (peace be upon him) brought it all down at once on Laylat al-Qadr, from al-Lawh al-Mahfooz to the lowest heaven, to Bayt al-'Izzah, and Jibreel dictated it to the angelic scribes, then Jibreel brought it down to the Prophet (blessings and peace of Allah be upon him) piecemeal, and between the first and the last of it there were twenty-three years. This was stated by Ibn 'Abbaas." (Tafseer at-Tabari  20/129).
Al-Haafiz Ibn Hajar said: The Battle of Badr took place in Ramadan of the second year AH, and during that year fasting was made obligatory." (Fath al-Baari  1/50).
For more information on the sending down of the Quran piecemeal, please see the answer to question no. 180883 .
And Allah knows best.