Hope this helps. There the selects, then calling the function and then the function itself.
<?php
echo<<<EOD
<td rowspan=2>".input_select("manufact[]", $man_arr, $man, "", "", "multiple=yes")."</tD>
<td rowspan=2>".input_select("family[]", $fam_arr, $fam, "", "", "multiple=yes")."</tD>
<td rowspan=2>".input_select("model[]", $mod_arr, $mod, "", "", "multiple=yes")."</tD>
EOD;
InsertNewAcc( $manufact, "M" );
InsertNewAcc( $family, "F" );
InsertNewAcc( $moddel, "D" );
function InsertNewAcc( $idvalue, $insert_flag ) {
global $id;
$manid = 0;
$famid = 0;
$modelid = 0;
$count = count( $idvalue );
foreach( $idvalue as $key => $value){
if( $insert_flag == 'M' ) $manid = $idvalue[$key];
if( $insert_flag == 'F' ) $famid = $idvalue[$key];
if( $insert_flag == 'D' ) $modid = $idvalue[$key];
if ( ( $manid > "" ) Or ( $famid > "" ) OR ( $modid > "" ) ) {
$qry = "SELECT modelid, famid, manid, ntbid FROM accessory_model
Where modelid = $modelid and famid = $famid and manid = $manid and ntbid = $id";
$res = mysql_query($qry);
$count = mysql_num_rows( $res );
if ( $count == 0 ) {
$sqlqry = "INSERT INTO accessory_model ( modelid, famid, manid, ntbid )
VALUES ( '$modelid', '$famid', '$manid', '$id' )";
mysql_query($sqlqry);
}
}
}
?>