This topic is locked
[SOLVED]

 Subfilter SQL Query Based on Hyperlink Clicked on List Page

9/10/2012 4:57:58 PM
PHPRunner General questions
D
dangdk author

Hi,
I have very limited knowledge of PHP but have managed with the help of PHP runner to get most of what I wanted done.
At the moment I am getting the SQL query returned from a search by using $strSQL. I use this, and a further AND condition, to give a few lines (beofe the list of items) describing the number of items in each category (and subdivision of that category) via another number of queries.
What I want now is to have this number as a hyperlink that the user can click and can filter the existing query according to that category, rather than filter the whole list. The list page will then refresh with the results of this new query.
i.e. the user may do a search for factories in the "USA" and after this search is done the list page loads with a few lines in my page above the sample list where the number of "Operational", "In Construction" and "Planned" facilities are listed for this search criterion(s). If the user clicks on "Operational" I want the list page to update with those ones in the USA that are operational, i.e. the query is filtered.
If possible I would like $strSQL to then equal this new full query (i.e. USA and Operational) so that my existing google maps routines and other things will still work.
Any help would be much appreciated <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=20035&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />

R
rencenji.denes 9/11/2012

Hi!
There are many ways to do that.
The easiest way to use the simple or advanced search panel where you can select the necessary values from fields.
Or you can create a php snipplets with a dropdown list box which is refresh automatically the page:
//create dropdown box
$str = "";
$str.= "<select onchange=\"window.location.href=this.options[this.
selectedIndex].value;\"><option value=\"\">Please select</option>";
//select values from database
global $conn;
$strSQL = "select company from tablename";
$rs = db_query($strSQL,$conn);
while ($data = db_fetch_array($rs))
$str.="<option value=\"tablename_list.php?ctlSearchFor=".$data["company"].
"&srchOptShowStatus=1&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=
integrated&id=1&criteria=and&type1=&value11=".$data["company"].
"&field1=company&option1=Contains&not1=a=search&value=1\">".
$data["company"]."</option>";
$str.="</select>";
echo $str;
BR:
Dennis

D
dangdk author 9/11/2012

Thanks for your reply Dennis. I have looked at the code and I think it will not be able to do what I am looking for. Your code appears to be making a new query from an option in a dropdown box, however I want to make an additional condition to the last query that populated the list page in order to subfilter further what is listed. I think my pictures below should help to describe this:

  1. When the list page initially loads all samples (factories) are in the list. I have populated a google map with the locations of these and have also provided a summary of the numbers of factories of each type (the lines next to the google map, above the list). See the linked picture for this. I would like these lines (for the facility numbers, e.g. Operational, In Construction etc.) to be hyperlinks that, when clicked, will filter out only that category. When there has been no previous query then this is easy since I can do an Field1, Value1 etc. href like you list in your code.


However....the user may use a search criterion or click another element on the list page and the list page reloads based on that filter, for example in this instance (picture below) the user has searched for all "hydrolysis" type facilities that are in the USA (using the search page). That provides the following url in the search bar on the list page.
http://localhost:8085/Commercial_and_Pilot_Facilities_list.php?a=integrated&simpleSrchFieldsComboOpt=&simpleSrchTypeComboNot=&simpleSrchTypeComboOpt=&criteria=and&type1=&value11=Hydrolysis&field1=process1&option1=Contains&not1=&type2=&value21=USA&field2=country_facility&option2=Contains&not2=
The list page then loads and you can see that the numbers for the facility types next to the map have changed, reflecting the results of this query.


I want the user to be able to click on the numbers for these type (e.g. Operational (2)) and the previous query will be further filtered to just list those two facilities. As far as I gather, under your code clicking on that line would open the list page again with a list of all of the Operational Demonstration Scale facilities rather than just the "Hydrolysis" ones in the USA. Now, if I knew the number of fields in the query I guess I could get the URL of the last query and add a search criterion to it but there may be a different number of search values in the last query (e.g. maybe the user just searched for the USA (1 field)or maybe he searched for hydrolysis facilities in the USA producing ethanol (3 fields).
I really hope you can help with this! Thanks <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=67709&image=3&table=forumreplies' class='bbc_emoticon' alt=':)' />



Hi!
There are many ways to do that.
The easiest way to use the simple or advanced search panel where you can select the necessary values from fields.
Or you can create a php snipplets with a dropdown list box which is refresh automatically the page:
//create dropdown box
$str = "";
$str.= "<select onchange=\"window.location.href=this.options[this.
selectedIndex].value;\"><option value=\"\">Please select</option>";
//select values from database
global $conn;
$strSQL = "select company from tablename";
$rs = db_query($strSQL,$conn);
while ($data = db_fetch_array($rs))
$str.="<option value=\"tablename_list.php?ctlSearchFor=".$data["company"].
"&srchOptShowStatus=1&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=
integrated&id=1&criteria=and&type1=&value11=".$data["company"].
"&field1=company&option1=Contains&not1=a=search&value=1\">".
$data["company"]."</option>";
$str.="</select>";
echo $str;
BR:
Dennis