I have a problem. I'd like to have php+mysql database based rolling chat.
There would be messages like msg1 msg2 msg3 msg4 rolling all the time like a scroller. That was the easy part. But when user is typing msg5 and we are example in position msg2 so the msg5 should came between msg2 and msg3.
So after user input it should be msg1 msg2 msg5 msg3 msg4.
What would be the best way to "index" these messages..
example: before user input text is scrolling like this.
id ----- position
1 msg1 1
2 msg2 2
3 msg3 3
4 msg4 4
after: user input it should look like this.
id ----- position
1 msg1 1
2 msg2 2
3 msg3 4
4 msg4 5
5 msg5 3
If there is going to be n+1 messages it can't be very fast to add position number to every msg after newest with for($i=$position;$i<count($msgs);$i++)..
Hopefully someone undestands what I mean 🙂