Announcement

Collapse
No announcement yet.

Search dropdown options

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Search dropdown options

    I have spent couple of hours trying to figure out how this is done:

    Exapmple 1 : http://www.sitepointforums.com
    At the top right corner, there is one input field for the search and then a dropdown with options "Forums" and "Articles"
    Each option searches a different database and needs to send the keyword data to a different file...
    Exapmple 2: http://www.overgrow.com/edge/index.php
    Same case, at the top right corner, there is one input field, and 3 options on what to search. Again, the file that the data needs to be sent differs for each option I am sure.

    The coding that I am looking for is the PHP part of all this, the actual search.php to which the data is submitted. I need to figure out on how to redirect the data depending on which option is selected from the dropdown.. does anyone understand what I am saying?

    Thanks for any help.
    Webmaster
    http://www.AutomotiveForums.com

  • #2
    yes... i do.

    you either right search.php to have the code to search both sections if you see what i mean and just do an if ($action == "forums") search forums...

    or i guess you could do it with an include statement so

    [php]
    if ($action == "forums") {
    include('./forum_search.php');
    }

    but i am not sure how that would work.

    Another way would be to have an extra intermediate page.. but you would have to build up the url from the variables you can expect.
    Christopher Padfield
    Web Based Helpdesk
    DeskPRO v3.0.3 Released - Download Demo Now!

    Comment


    • #3
      You rule for helping me!

      ...but.... I don't get it..


      Can you please make it a little more detailed?

      Thanks
      Webmaster
      http://www.AutomotiveForums.com

      Comment


      • #4
        Ok.. as you asked nicely here we go.

        You have two types of programs you want to search. Each contains a different search system.

        Now the easiest thing to do, assuming they are both php is merge them together into one file. Then all you do is tell the script to only do part of that script, depending on the value of the drop down menu.

        Now, if your other search system is not in PHP you have a bit of a problem because my other solutions won't work. The only thing i can think of is having an intermediate script. How would this work...

        Well... say you had search.cgi and search.php and both programs were expecting the search term variable $keyword (from the name of the text input field in the form).

        Now, you create a drop down menu which asks if you want to search the forums or search your articles say. You call one forums, one articles. You direct the search results to search_selector.php

        now search_selector.php is something like

        PHP Code:
        <?php
        if ($search_type == "forums") {
        standardredirect('search.php?keyword=$keyword);
        } elseif ($search_type == "articles") {
        standardredirect('
        search.cgi?keyword=$keyword);
        }
        ?>
        see?

        now i can't remember what the standardredirect function is looking for but you could make something that uses it (have a look in functions for something based on this).

        Of course, the first method (which i can elaborate on) is better but requires both of your search systems use PHP and you can put the code from the other file in search.php

        I won't be able to answer any more questions now, off to bed but will look 2morrow.
        Christopher Padfield
        Web Based Helpdesk
        DeskPRO v3.0.3 Released - Download Demo Now!

        Comment


        • #5
          You might want to try Anaconda Director. It's a free download and makes easy work of what you need.
          http://britishexpats.com/ - British expatriate community

          Comment


          • #6
            Great program fastfoward! Thanks for the recomendation!

            Comment


            • #7
              beware, they encrypt their programs so don't plan on being able to edit it.
              Christopher Padfield
              Web Based Helpdesk
              DeskPRO v3.0.3 Released - Download Demo Now!

              Comment


              • #8
                ahh okay I just thought they were using real crazy vars but I thought it looked like encrpytion. tks for the heads up, I commonly haxor scripts to suit me.

                Comment

                Loading...
                Working...
                X