The qur'an mentiones the possible three positions for dhikr Allah twice:
- In surat al-'Imran:
Who remember Allah while standing or sitting or [lying] on their sides and give thought to the creation of the heavens and the earth, [saying], "Our Lord, You did not create this aimlessly; exalted are You [above such a thing]; then protect us from the punishment of the Fire. (3:191)
- In surat an-Nisa':
And when you have completed the prayer, remember Allah standing, sitting, or [lying] on your sides. But when you become secure, re-establish [regular] prayer. Indeed, prayer has been decreed upon the believers a decree of specified times. (4:103)
In his tafsir of verse (3:191) imam al-Qurtobi commented on the possibility of this verse referring to the prayer and quoted some fiqh views on the part about lying on their sides (My own translation take it carefully):
الخامسة : قال : فإن لم يستطع القعود صلى على جنبه أو ظهره على التخيير ، هذا مذهب المدونة ، وحكى ابن حبيب عن ابن القاسم يصلي على ظهره ، فإن لم يستطع فعلى جنبه الأيمن ثم على جنبه الأيسر .
The fifth issue: He (the autor) said: "If he (the sick person as mentioned in the issues before) can't sit he can pray lying at his side or his back and here he has a free choice (what ever seems convenient for him) this is the opinion presented in al-Mudawwana (a Maliki book which was written by Suhnun or Sahnun). And ibn Habib (a Maliki scholar and student of ibn al-Qassim from al-Andalus) has narrated from ibn al-Qassim "he should pray on his back, and if he was not able to then on his right side else on his left side".
وفي كتاب ابن المواز عكسه ، يصلي على جنبه الأيمن ، وإلا فعلى الأيسر ، وإلا فعلى الظهر .
And in the book (called al-Muwaaziya الموازية a book on Maliki fiqh) of ibn al-Muwaaz (died 269 a.H.) the opposite of this is mentioned: "pray on the right side, if not possible on the left side else on the back"
وقال سحنون : يصلي على الأيمن كما يجعل في لحده ، وإلا فعلى ظهره وإلا فعلى الأيسر .
And Sahnun said: He pray lying on the right side as he would be placed in his coffin, if this isn't possible to him then on his back else on the left side.
وقال مالك وأبو حنيفة : إذا صلى مضطجعا تكون رجلاه مما يلي القبلة .
Malik and abu Hanifa said: if one prays lying (on one side or the back) then his feet should point to the qiblah.
والشافعي والثوري : يصلي على جنبه ووجهه إلى القبلة .
a-Shafi'i and a-Thawri said: He prays on his side while he is facing the qiblah
Note that if one is able to sit or stand -for a fard prayer- one is not allowed to pray lying down, one should have this in mind, as praying while standing is considered as a fard or rukn (pillar) -for those who are able to- by all four sunni madhhabs.
Also note thta it seems that the hanbali view is as follow: The most preefrable position is on the right side, the the left side and then on the back the feet towrads the qiblah (according to a fatwa of ibn Baz).
Here some more details from a commentary of the maliki book ar-Rissala (Chapter Twelve: 12.9 the prayer of a sick person):
If he cannot sit on his own or supported or cross-legged or
otherwise, he prays on side with his face towards qibla as he
would be in the grave. If he cannot go on his right side, then on his
left side.
If he can only pray on his back, he gestures with his feet to qibla.
If he is unable to pray on his back, he prays lying on his stomach
with his face to qibla and his feet behind him. The judgment about
facing qibla in those states is that it is obligatory when he has the
ability to do so. If he prays to other than the qibla when he is able
to face it, the prayer is invalid. The ability is when there is
someone who is able to move him. If he finds someone to move him
after the prayer, it is recommended that he repeat it within the
time.
The one who prays lying down indicates with his head. If he is
unable to indicate with his head, he indicates with his eyes and
eyebrows. If he cannot do this, then it is with his finger. The
literal text as Shaikh al-Ujhuri (rahmatullahi alaihi) said is that
the order in the gesture using these three is obligatory.
(From ath-Thamr ad-Dani the commentary of the ar-Rissala of abi Zayd al-Qayrawani See here List of Islam-related books (in English))
Al-Jaziri in his Jurisprudence of the four sunni schools (page 296) quotes that standing is considered an obligatory pillar by all four madhhabs, but this requirement is waived if somebody is not able to for illness or any valid reason. Later when discussing the prayer of an ill person who is neither able to bow or prostrate (page 666-667) he says that such a person who ...
... can't perform any part of the prayer except by a movement of his eyes or by pondering its actions in his heart, he must do so, and this obligation remains as long as he is mentally alert.
According this book as long as one is able to gesture with his eyes he must do so and pray according to the Malki's, Shafi'is and Hanbali's, while the Hanafi's say the obligation to pray is waived as they consider such a prayer invalid.