Need help with some logic in my sketch.

Agreed. But my App for my phone doesn't call the page and then add the ?LEDn it just sends the get request xxx.xxx.xxx.xxx/?LEDn. If I knew how to do what it is you're talking about I probably wouldn't be asking in the forums. Do you have any example code I can look at?