Jump to content

Help me add the "All" option to the Search Form


Chrisj

Recommended Posts

I'm using a PHP script which has this Search Form:

     <form method="get" action="search.php" autocomplete="off" name="form_search">

        <select size="1" name="type" />
        <option value="videos">[var.lang_word_videos]</option>
        <option value="images">[var.lang_word_images]<!--[onload;block=option;when [var.enable_images]=1;comm]--></option>
    	</select>

    	<input autocomplete="off" id="keyword" name="keyword" value="Search [var.site_name]" onclick="clickclear(this, 'Search [var.site_name]')" onblur="clickrecall(this,'Search [var.site_name]')" />
    	<input type="submit" value="Search" />
      </form>

How can I add an "All" option, so it can search both images and videos? Is it simply this?

<option value="all">All</option>

And then I would need to sync that in the search.php file? Can someone help with that part too?

Link to comment
Share on other sites

Chrisj, the code you posted is only for the FORM which the user will interact with to send data to the server. So, "yes" to your first question you can add an option like you have shown. But, that is only half of the problem.

 

Somewhere within the "search.php" page (or other code that is included on that page) there is logic to use the data sent by the user. There will be some code that takes the value of $_GET['type'] and uses it to query for the right records. What he provided is only an example as we have no clue how that logic is currently built. You will need to figure that out or at least provide us the relevant code. Look in the "search.php" file for a reference to $_GET['type'] and a query to retrieve the records.

Link to comment
Share on other sites

the OP's script is (he posted the code on one of the many forums he is asking this on) the phpmotion video/image/audio/blog/group sharing script.
 
the information for each 'type' is stored in a different table with a few different column names/meaning between the tables and there's a switch/case statement on the type value to determine what columns to select and to select a table name where the related comments are stored, which are accessed by running another select query inside of a loop.
 
this script looks like it is basically five independent scripts that were forced together. most of the code in the search.php file is so bad and out of date (@ error suppressors, ereg, msyql statements, string escaping things that aren't strings, no validation of the type value - you can enter a value that's not one of the choices and trigger all kinds of errors...) that it wouldn't be worth anyone's time trying to make to work.

@Chrisj, if you want to have an 'ALL' search choice, you need to start with a script that properly stores the primary and related data in a normalized fashion. If the original Authors of this script had done this, there would be very little program logic present and doing the things that have been suggested, which assume that the type choice is just a value in a column in one single table, would be simple.

 

edit: this script is also using an equally bad template system called TBS (Tiny But Strong), which i think was authored by the same people as the phpmotion script.

Edited by mac_gyver
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.