Hi Andy.

Ive had a look at the Javascript, but I have over 90 pages that are all going to have different sub-criteria - i.e. once Ive sorted the county, you will be taken to a page where you will then chose which district (or all) you want to view.

I want to keep all of this dynamic ( I might add a new district to the databse) so as to avoid having to keep changing the Web site itself.

That is of course, unless I`m getting confused. Are you saying it is possible to use OnChange after dynamically generating $row["County"] and $row["HRef"] and re-directing to the correct $row["HRef"] ??? If so, that will do fine. Please tell me how I do it....

    OK, I`m getting there - from browsing this forum I know now that I need to use SOME javascript, window.open for instance.

    The main problem I have left is how to link up the SELECTED county from the dropdown list, to the corresponding HRef stored in the array.

    For instance, if they select say, Berkshire, and it`s the 4th element in County, I need the window.open to have a variable in it, drawn from the array, that will be the 4th element in the HRef part.

    Am I making sense???

      Not sure what you're last post meant... but hopefully this will be of some help...

      ----- pagenumberone.html -----------

      <form name="formname" method="get" action="redirect.php">

      <select name="redirect" onchange="javascript:document.formname.submit()">

      <?php

      $result = mysql_query ("SELECT href, country FROM whatever WHERE country = 2");
      while ($array = mysql_fetch_array ($result)) {

      print ("<option value=\"" . $array['href'] . "\">" . $array['country'] . "</option>

      </select>

      </form>

      ------ end pagenumberone.html --------

      ------ redirect.php --------------------------

      <?php

      if ($_GET['href']) {

      header ("Location: " . $_GET['href']);
      exit;

      ?>

      --------- end of redirect.php =-----------------

      Is that what you mean to do?

        Hi, thanks for the reply.

        It is certainly a step closer I think. It is basically doing what I was trying to do, but it is using the HEADER function.

        Unfortuantely, like mine, it is not working. I`m not sure why, but the page is not being directed anywhere. Either the $_GET['HRef'] in redirect.php is not being passed any parameters, or something.

        The parameter that is supposed to be passed, will it be the actual value in the option, or the one that is currently being pointed to in the array? This is what I was trying to say in my last post. i.e. don`t I want to somehow get the option value, rather that the variable which will have changed?

          Instead of using that header redirect option I do it the same way as it is done on the forums here -

          <select name="forumid" onchange="window.location=('forumdisplay.php?s=&daysprune=&forumid='+this.options[this.selectedIndex].value)">

          change this to -

          <select name="forumid" onchange="window.location=(this.options[this.selectedIndex].value)">

          Hope this helps 😉

            Can you post your code...?

            My code works fine for me...

              Yeah, no probs. Obviously I changed it slightly to fit in with my existing code, etc. Hope by doing that I didn`t mess it up....

              <form name="formname" method="get" action="redirect.php">
              <select name="redirect" onchange="java script:document.formname.submit()">

              <?php

              $cursor = mysql_query("select distinct County, HRef from Main order by County asc");
              if (!$cursor)
              {
              echo("<H3>MySQL error: " . mysql_error() . "</H3>");
              exit();
              }
              while ( $row = mysql_fetch_array($cursor) )

              {
              printf ("<option value = ". $row["HRef"] . ">" . $row["County"] . "</option>");
              }
              ?>

              </select>

              </form>

              Thanks for your help.

                nnichols, its always nice to have a few ways of doing things. So how would my HRef fit into your way of doing it? I dont quite follow. Thanks for the interest!

                  Erp thing I made a mistake, try this on redirect page:

                  <?php

                  header ("Location: " . $_GET['redirect']);

                  ?>

                  And if that doesnt work, you might be using an old version of PHP, so:

                  <?php

                  header ("Location: " . $HTTP_GET_VARS['redirect']);

                  ?>

                    <select name="forumid" onchange="window.location=(this.options[this.selectedIndex].value)">
                    <option value="href">text</option>
                    <option value="href">text</option>
                    <option value="href">text</option>
                    </select>

                    It will take the value from the selected option and use it in the window.location()

                    Hope this helps 😉

                      Nope! Sorry, neither worked. Well annoying. Quick thought, my redirect.php is in the same sub directory as the page Im accessing it from - they dont both (or either) have to be in the root do they? (Stab in the dark from Al)

                        Thanks nnichols. I see what you mean. The trouble with that is that the dropdown list is not dynamically generated. I might have to use it as an intrim measure to get it working, but I want to be able to add new Counties into the database as it grows, without extra work on the site.

                        Tell you what I HAVE noticed, the database is not completely populated yet. The few HRefs I do have, mean that the corresponding County appears TWICE in the dropdown list - so there must be something going wrong there! Does that help anybody?

                          Nope, what I suggest you do is put this on your redirect page...

                          It does actually submit to your redirect page correct? Does it give you any errors? Does the redirect page just show you a blank screen or...?

                          <?php

                          foreach ($_GET as $key => $value) {
                          print ($key . " = " . $value . "<br />");
                          }

                          foreach ($_POST as $key => $value) {
                          print ($key . " = " . $value . "<br />");
                          }

                          foreach ($_REQUEST as $key => $value) {
                          print ($key . " = " . $value . "<br />");
                          }

                          ?>

                          And see if it prints out the HRef variable...

                            I don`t think the redirect is being accessed at all. I get no error messages, and that script you gave me does not run. Bizarre!

                              You can make it dynamically generated easily -

                              <select name="forumid" onchange="window.location=(this.options[this.selectedIndex].value)"> 
                              <?
                              $res = //do your query stuff
                              while ( $row = mysql_fetch_array($res)) { 
                              printf ("<option value = ". $row["HRef"] . ">" . $row["County"] . "</option>"); 
                              } 
                              ?> 
                              
                              </select>

                                Woah woah woah... do you or dont you actually get sent to:

                                redirect.php

                                ? Cause if you don't get sent there then thats the reason sheesh. How can it redirect you if you never get to the redirect page?

                                Try this for the selectbox, no Javascirpt, and click the button:

                                <form name="formname" method="get" action="redirect.php">

                                <select name="redirect">

                                <?php

                                $result = mysql_query ("SELECT href, country FROM whatever WHERE country = 2");
                                while ($array = mysql_fetch_array ($result)) {

                                print ("<option value=\"" . $array['href'] . "\">" . $array['country'] . "</option> ");

                                ?>

                                </select>

                                <input type="submit" value="Go!">

                                </form>

                                  nnichols, that code to dynamicalluy generate the dropdown is exactly what Im using. Excuse me for being thick, Im new to all this (you don`t say?), but where would $row["HRef"], ie the actual option value, fit into

                                  <select name="forumid" onchange="window.location=(this.options[this.selectedIndex].value)">

                                  There is also something else fundamentaly wrong. Every County that has a corresponding entry in the HRef field in the database is appearing twice in the dropdown. I have no idea why that is!

                                    it is actually generating the HTML correctly right? php and apache are working...

                                    right?

                                    can you show us the HTML its generating...?

                                      superwormy, thank youfor your patience. NOW, when I click the GO button, I get:

                                      redirect =
                                      redirect =

                                      PHP is definately working, as I have loads of other pages that pull data fromthe database. How do I know about apache?

                                        WAIT WAIT WAIT!!!! Sorry, little mistake on my part.

                                        Right, when I select a county that HAS got a corresponding HRef (DOH!) I get

                                        redirect = correct URL