Problem on information in dropdown

First, thanks for your help. Here is what I have… in add_p_mat.php there is the following:

require_once “include/functions.php”;

Material ID: <? ECHO getDropDown( materials, id, matName );?> === where getDropDown is defined in functions.php as the following: <? ... function getDropDown($TBL,$VAL_ID,$VAL_NAME,$CURRENT = "",$COND = "") { $query2 = "SELECT * FROM $TBL $COND ORDER BY $VAL_NAME"; $result2 = mysql_query($query2) or die("Query error: getDropDown() ".mysql_error()."
$query2"); while ( $row2 = mysql_fetch_object($result2) ) { eval("\$ret_out .= \"$VAL_ID\";"); eval("if ( \$CURRENT == \$row2->$VAL_ID ) \$ret_out .= \" selected\";"); eval("\$ret_out .= \">\".stripslashes(\$row2->$VAL_NAME).\"\n\";"); } return $ret_out; } ... ?> ===

The following information is contained in the materials table
id matType matName matDescr productCode qty

What I’d like to be able to do is to have “matType:matName” in the drop down box, not just “matName”, and it would be even better if the drop down sorts by matType. I’d appreciate some ideas. Thanks

I’m not expert so if I’m wrong maybe someone can correct me but it looks like you’re going to get the same result from the table for every option in your table as a function can only return a single value and you’re not telling it to grab a specific row from the query for every option.

I would have the function grab the information from a database and put it into an array, return that, then use a loop to create your dropdown list.

Sponsor our Newsletter | Privacy Policy | Terms of Service