Array and ID

admin

Administrator
Staff member
I have a drop-down menu that has been prepopulated with an array from a
column name CompanyName. What I need to do is take the CompanyName lookup
the CompanyID in the company table and insert the CompanyID into a row in a
table called contacts with a CompnayID column.

Any suggestions?

// create SQL statement
$sql = "SELECT CompanyName,CompanyID FROM company
ORDER BY CompanyName ASC";

// execute SQL query and get result
$sql_result = mysql_query($sql,$connection)
or die("Couldn't execute query.");

// put data into drop-down list box
while ($row = mysql_fetch_array($sql_result)) {

$CompanyName = $row["CompanyName"];

if ($curr_CompanyName == $CompanyName) {

$option_block .= "<OPTION name=\"$CompanyID\" value=http://www.phpbuilder.com/board/archive/index.php/\"$CompanyName\"
selected>$CompanyName</OPTION>";

} else {

$option_block .= "<OPTION name=\"$CompanyID\"
value=\"$CompanyName\">$CompanyName</OPTION>";

}
}




?>
 
Back
Top