This topic is locked

How to put Advanced Search on the List Page

9/10/2009 11:06:22 PM
PHPRunner General questions
D
d_gan author

I have tried using this code but it only can filter 1 column. I would like to filter multiple column without going into advanced search page. I have tried to copy code from tablename_search.php to my list.php page but nothing show up.

//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?a=search&value=1&SearchFor=".$data["company"]."&SearchOption=Contains&SearchField=company\">".$data["company"]."</option>";
$str.="</select>";

echo $str;
D
d_gan author 9/12/2009

I found the solution myself, Just for your info I post my own solution.
First, enable all fields in Advanced Search in chose field.

In Visual Editor add Event Snippet on TABLENAME List page with following code,
To filter by with Lookup option

If you want to use OR option in Advance Search

at "<input type=\"hidden\" name=\"type\" value=\"[color="#FF0000"]and\">" replace with OR

Replace TABLENAME with your own tablename
Event Snippet

echo "<form name=\"editform\" action=\"TABLENAME_list.php\" method=\"get\">";

echo "<input id=\"a\" type=\"hidden\" value=\"advsearch\" name=\"a\"/>";

echo "<input type=\"hidden\" name=\"type\" value=\"and\">";
$sql="select Field1 from TABLE";

$result=mysql_query($sql);

$options="";

while ($row=mysql_fetch_array($result)) {

$thing=$row["Field1"];

$options.="
<OPTION VALUE=\"$thing\">".$thing;

}

echo "<B>Search for &nbsp;</B>";

echo "<input type=\"hidden\" name=\"asearchfield[]\" value=\"Field1\">";

echo "<input type=\"hidden\" ID=\"SearchOption\" NAME=\"asearchopt_Field1\" value=\"Equals\" >";

echo "<SELECT id=value_Field1 name=value_Field1><OPTION value=>Field1";

echo "<?=$options";

echo "</SELECT>";

echo "<input type=\"hidden\" id=\"value1_Field1\" name=\"value1_Field1\" value=\"\">";

echo " &nbsp;";

$sql1="select DISTINCT `Field3` from `TABLENAME`";

$result1=mysql_query($sql1);

$options1="";

while ($row1=mysql_fetch_array($result1)) {

$thing1=$row1["Field3"];

$options1.="
<OPTION VALUE=\"$thing1\">".$thing1;

}

echo "<input type=\"hidden\" name=\"asearchfield[]\" value=\"Field31\">";

echo "<input type=\"hidden\" ID=\"SearchOption\" NAME=\"asearchopt_Field3\" value=\"Contains\">";

echo "<SELECT id=value_Field3 name=value_Field3><OPTION value=>Field3";

echo "<?=$options1";

echo "</SELECT>";

echo "<input type=\"hidden\" id=\"value1_Field3\" name=\"value1_Field3\" value=\"\">";
echo " &nbsp;";
$sql2="select DISTINCT `Field2` from `TABLENAME`";

$result2=mysql_query($sql2);

$options2="";

while ($row2=mysql_fetch_array($result2)) {

$thing2=$row2["Field2"];

$options2.="
<OPTION VALUE=\"$thing2\">".$thing2;

}

echo "<input type=\"hidden\" name=\"asearchfield[]\" value=\"Field2\">";

echo "<input type=\"hidden\" ID=\"SearchOption\" NAME=\"asearchopt_Field2\" value=\"Contains\">";

echo "<SELECT id=value_Field2 name=value_Field2><OPTION value=>Field2";

echo "<?=$options2";

echo "</SELECT>";

echo "<input type=\"hidden\" id=\"value1_Field2\" name=\"value1_Field2\" value=\"\">";
echo " &nbsp;";

echo "<span class=\"buttonborder\"><input type=\"button\" onclick=\"javascript:document.forms.editform.submit();\" name=\"SearchButton\" value=\"Search\" class=\"button\"/></span>";
echo "</form>";
D
danaci 9/12/2009

Congratulations and thank you

Admin 9/12/2009

Just for your info - we are adding this feature (configurable Advanced search on List page) in PHPRunner 5.2.
Expect live demo posted to forums next week.