Actually, you can see from my PHP code that I'm not closing the li right after creation of it. I'm putting the data in the li and then closing it. Then why the li is getting closed right after creation of it in resulted HTML? Can anyone help me in this regard? Thanks in advance.

2 Answers
2

this is because you cannot put li directly inside another li.
You need to create a list under li first (ul or ol) or the browser will assume that you simply forgot about </li> and will close this tag for you