This topic is locked

Dropdown menu - select records

1/11/2006 2:54:43 PM
PHPRunner General questions
E
ericjlars author

I have a row called "city" I would like to add a dropdown menu at the top of the page, so if a user selects los angeles, only records with los angeles will show.. Is there a way to do this?

Sergey Kornilov admin 1/11/2006

What page (List, Edit, Search) you talking about?

E
ericjlars author 1/11/2006

This would be for the list page

Sergey Kornilov admin 1/12/2006

Hi,
you can use Advanced Search page to filter records by values selected from dropdown list.
Also you can modify PHPRunner-created List page to add a dropdown that will start search by city name.

However this task requires some custom programming.

J
jose2250 4/18/2008

Hi,

you can use Advanced Search page to filter records by values selected from dropdown list.
Also you can modify PHPRunner-created List page to add a dropdown that will start search by city name.

However this task requires some custom programming.


I want accomplish the same thing in the ??_list.php page.

So, how much custom programming is needed here?

Isn't a few lines of code that you can send us?

Please let me know. Thanks!

J
Jane 4/21/2008

Answered in your personal email.

S
stevenf 4/21/2008

Hi Jane,
Could I have this answer emailed to me too please? As I want to do the same thing!
Hope you can help.
Thanks
Steven.

J
Jane 4/22/2008

Hi,
you can do it using custom event (Insert PHP code snippet option on the Visual Editor tab).

Here is a sample:

//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>";
</select>";

echo $str;

S
stevenf 4/22/2008
J
jose2250 4/23/2008

Hi Jane,

I inserted the code snipped as you suggested, however when I tried I get the following error: Parse error: syntax error, unexpected '<' in /home/mundohispanico/www/www/newsbudget/include/budget_main_events.php on line 53
Here is the code I inserted:

--------------------------------------

//create dropdown box

$str = "";

$str.= "<select onchange=\"window.location.href=this.options[this.selectedIndex].value;\">

<option value=\"\">Select Company</option>";
//select values from database

global $conn;

$strSQL = "SELECT Company,Company Name FROM company";

$rs = db_query($strSQL,$conn);

while ($data = db_fetch_array($rs))

$str.="<option value=\"budget_main_list.php?a=search&value=1&SearchFor=".$data["Company"]."&SearchOption=Contains&SearchField=Company\">".$data["Company"]."</option>";
</select>";

echo $str;

--------------------------------------

Hi,

you can do it using custom event (Insert PHP code snippet option on the Visual Editor tab).

Here is a sample:

J
jose2250 4/23/2008

Did you try this code Steven? Any luck?

Great!

Thanks a lot <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=28389&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

J
Jane 4/23/2008

Hi,
sorry for my fault.

Here is the correct code:

//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;

J
jose2250 4/23/2008

Excellent!

THANK YOU VERY MUCH Jane. Wow, I got worry. It worked perfect. I modified it to show the Name Company instead of Company in the dropdown. It worked fine and filter the list as programmed. Thanks!
*** Now that I know, I can add this code to any other of my _list pages if needed.
Question: Jane, to make it more friendly for my users, how can I add a second criteria search dopdown menu....next to this Company, to allow users to select 'Company' and 'Edition'? With the code you've provided, I think I can try, but if you can reply with it, it will be nice!

I appreciate it!

Hi,

sorry for my fault.

Here is the correct code:

J
Jane 4/23/2008

Jose,
you need to contact with this question support team at support@xlinesoft.com. Include your order number or registration email address.

J
jose2250 4/23/2008

I will do. Thanks!

Jose,

you need to contact with this question support team at support@xlinesoft.com. Include your order number or registration email address.

N
nix386 9/9/2008

Sorry to resurrect an old thread but I have a need for this code and it seems to work well but I have an issue where the dropdown seems to be populated with duplicate values for the search criteria.
I have a need to filter by state, my records all have this field present, but when I use the dropdown for the list page it shows duplicates for each state? Any assistance would be appreciated.
Nick

//create dropdown box

$str = "";

$str.= "<select onchange=\"window.location.href=this.options[this.selectedIndex].value;\"><option value=\"\">Filter by State</option>";
//select values from database

global $conn;

$strSQL = "select state from master_table";

$rs = db_query($strSQL,$conn);

while ($data = db_fetch_array($rs))

$str.="<option value=\master_table_list.php?a=search&value=1&SearchFor=".$data["state"]."&SearchOption=Equals&SearchField=state\">".$data["state"]."</option>";

$str.="</select>";

echo $str;
J
Jane 9/9/2008

Hi,
just add DISTINCT clause to your query:

...

$strSQL = "select DISTINCT state from master_table";

...

N
nix386 9/9/2008

Doh! Of course, thanks Jane! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=32868&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />

Hi,

just add DISTINCT clause to your query:

F
fawad112 9/15/2008

[codebox]//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 writerid from accounts";

$rs = db_query($strSQL,$conn);

while ($data = db_fetch_array($rs))
$str.="<option value=\"tablename_list.php?a=search&value=1&SearchFor=".$data["writerid"]."&SearchOption=Contains&SearchField=company\">".$data["writerid"]."</option>";
$str.="</select>";

echo $str;[/codebox]
Hi,
I used the above code to get the list of value from a column and display the dropdown in each row of a certain table. I values are populating the dropdown box. But i don't want to use this for searching, i want this to update the certain fields of table related to that row. Like if the row where the dropdown menu is and the primary key field is "ref" of that row. Hope i explained what i want to do.
Thanks in advance.

F
fawad112 9/15/2008

Thanks i did it with other method .

I
illi 9/24/2008

Hello,
Your dropdown code is working really well for me...but I too would like to use a dropdown along with a dependent dropdown to filter the list page. Basically, "School" and then "Teacher" within that School. Any guidance?
Thanks!
Eric

J
Jepsen 9/24/2008

Exactly what I need too. Dependant drop down for each column on the list page would be elegant and extremely usefull.
Morten

Hello,

Your dropdown code is working really well for me...but I too would like to use a dropdown along with a dependent dropdown to filter the list page. Basically, "School" and then "Teacher" within that School. Any guidance?
Thanks!
Eric

T
thesofa 9/25/2008

I remember a couple of years ago this was asked for and a link was published , So I did some digging and found a cut and paste table filter .

I have no idea if it works, but it might save some hassle.

J
Jepsen 9/26/2008

I remember a couple of years ago this was asked for and a link was published , So I did some digging and found a cut and paste table filter .

I have no idea if it works, but it might save some hassle.


This was elegant
I would love to see this as an option in the PHPR list page. Something for the PHPR team to think about.
Unfortunately, I am not familiar enough with source programming to implement this on the pages. Tried with no success. The explanation given assumes that you know what you are doing from a start.

T
thesofa 9/26/2008

make an extra copy of it and just play, download the zip file for it and read all the examples, they are truly lovely.

That sounds a bit sad does it not?

N
nicolagrimshaw 10/1/2008



This was elegant
I would love to see this as an option in the PHPR list page. Something for the PHPR team to think about.
Unfortunately, I am not familiar enough with source programming to implement this on the pages. Tried with no success. The explanation given assumes that you know what you are doing from a start.


I agree, would be a great feature.... Not competent enough to do it myself!

R
runnerPHP2008 4/6/2009

I will do. Thanks!


Yes, I have paid for 1 year of support and I am looking for the same answer to this question...

Sergey Kornilov admin 4/6/2009

runnerPHP_2007,
you need to contact with this question support team at support@xlinesoft.com. Include your order number or registration email address.

hichem 4/8/2009

Thanks i did it with other method .



HI Fawad, can you please indicate what other method you have used, I am interested in the same functionality. many thanks.

Hich