Chrisj Posted June 1, 2016 Share Posted June 1, 2016 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? Quote Link to comment Share on other sites More sharing options...
Barand Posted June 1, 2016 Share Posted June 1, 2016 Yes. If they choose "videos" or "images" then you have SELECT ... WHERE type = :type If they select "All" then you just omit the WHERE clause Quote Link to comment Share on other sites More sharing options...
Chrisj Posted June 1, 2016 Author Share Posted June 1, 2016 Thank you for your reply. Much appreciated. Can you please give me more of an example of what you mean? Thanks Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 1, 2016 Share Posted June 1, 2016 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. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted June 2, 2016 Share Posted June 2, 2016 (edited) 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 June 2, 2016 by mac_gyver Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.