Basically, I have a historical chronology, listed by year. I want the ability for users to type a year in a text box at the top of the page, submit, and get redirected furthur down on the same page to the year they specified. Or if that year cannot be found, send them to the closest match. I would like to avoid adding a piece of code or anchor in front of every year in the chronology, since I have so many listings.

Any ideas? πŸ™‚

    php wont be able to do this task. you will either need to use anchors or use javascript. im sure there is some js code out there that can scroll the page up and down, but getting it to a certain year may be another task in itself once you get the js code.

      That's too bad. I'm surprised PHP can't do this. πŸ™

      I'll look around at JS's then. Thanks for the help! πŸ™‚

        the reason php can't do it is because php is server side, meaning php only lives on the remote server while the code is being compilated and executed. once the html output is generated and sent to the user, php is done and apache or whatever webserver in use takes over sending the html to the user. therefore, php has no control whatsoever over the user's browser and what it does. javascript, on the other hand, is client side, meaning the language is actually built into the users browser, so all the js code is run and controlled by their computer, so it is able to do a lot of things with the browser.

          Along the same lines (no pun intended)...

          Can I get PHP to echo the line number it is currently on? I've always wanted to be able to do this to help me with debugging. Obviously, it knows what line its on because anytime there is a parse error it tells you the line number. Is there any way though that I could have it echo that line number?

            Awesome! I had no idea that existed... thanksπŸ™‚

              4 years later

              Is there anyway to move the processing to a certain line of code based on an if statement?

                Yes, PHP has a variety of control flow statements for transferring processing from one part of the program to another (the if statement is one of them).

                  Write a Reply...