Abdullah bin Buraydah narrates from Imran bin Husayn (may Allah be pleased with him): I had haemorrhoids, so I asked the Prophet (peace and blessings be upon him). He (peace and blessings be upon him) said: "Pray standing; if you are unable, then pray sitting; and if you are unable even to do that, then pray lying on your side."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 5488