PIC16F877A (with LCD) not working
Your comment "Its working some times which may mean code is working." means (to me) that the hardware isn't fried (it wouldn't work at all otherwise) and that your software needs adjustment.
You might want to use an unused GPIO pin as a 'heartbeat' signal, and toggle it through various places in your while loop. This allows you to not only make sure your code isn't getting lost (with your simple program, it shouldn't be) but also whether or not your overall timing is valid. For example, you can set the pin before one of your delays then clear it afterwards. If you see the pin change state for 1 second, you know that your crystal is working, the PIC oscillator is set properly and that your delays are working.
There may be some incompatibility between the LCD driver you're using and the specific LCD that you're working with. You may need to tweak that LCD code - add extra delays, etc. until your LCD cooperates.
lcd_init() and a delay(1000) need to go outside the while loop, as others have said. You need that delay(1000) after calling lcd_init() before any commands are sent - you may need a slightly longer delay depending on your specific LCD hardware.
If you've added decoupling capacitors per the comments, please update your schematic sketch showing where you've added them. If you've updated your code, please update your code section.