This topic is locked

help extending help code sample (dropdown select)

5/8/2010 4:58:26 PM
PHPRunner General questions
A
AlexOZ author

In the help there is a code sample for "Add dropdown list box with values for search" http://xlinesoft.com/phprunner/docs/add_dropdown_list_box_with_values_for_search.htm
I'd like help to extend this sample to display a column of the lookup table but return its primary key to search in the list. This key is the foreign key in a list display as a lookup table.
I hope that makes sense.
Alex

Sergey Kornilov admin 5/10/2010

Try this (see my changes in red):

//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["[b][color="#FF0000"]id
"].
"&srchOptShowStatus=1&ctrlTypeComboStatus=0&srchWinShowStatus=0&a=integrated&id=1&criteria=and&type1=&value11=".
$data["id"]."&field1=company&option1=Contains&not1=a=search&value=1\">".$data["company"]."</option>";
$str.="</select>";
echo $str;