It wont work because you are assuming that postids are consecutive in db while they are not. For example you might have deleted the postid 3 in your db, however your code still tries to replace its pagetext..
If you want to stick with your code, your best bet is to get all pagetexts first with select (in 1 query) and then parse them (If your db is big this might be a problem though)
However what Firefly suggested is the best and easiest method to handle what you are trying to do, so if I were you I wouldnt bother with writing my own code.. My 2 cents..
|