for($i=1; $i<=($jumlah_row_tabel_atas+1); $i++)
                    {
                            $satuan =   $_POST['PP_row_'.$i.'_satuan'];
                            $word_2[$i]="SELECT id_unit FROM manage_unit WHERE name_unit = '$satuan'";
                            $q[$i] = mysql_query($word_2[$i]);
                            $data_X = mysql_fetch_array($q[$i]);
                            $id_unit = $data_X['id_unit'];
                            $harga_1 = $_POST['PP_row_'.$i.'_harga_1'];
                            $harga_2 = $_POST['PP_row_'.$i.'_harga_2'];
                            $harga_3 = $_POST['PP_row_'.$i.'_harga_3'];
                            $id_drug = $_POST['id_drug'];
                            $value = $value_array[$i];
                            $word="INSERT INTO relation_mu_and_unit (id_drug, id_unit, priority, value, harga1, harga2, harga3, last_edit) VALUES 
                                                                            ( $id_drug,$id_unit, $i, $value, $harga_1, $harga_2, $harga_3, NOW() );";

                             mysqli_multi_query($word);
                    }

how to execute multiple query. I just can execute one query

1) You must concate $word. In your code u assiging new query

$word .= "INSERT INTO relation_mu_and_unit (id_drug, id_unit, priority, value, harga1, harga2, harga3, last_edit) VALUES ( $id_drug,$id_unit, $i, $value, $harga_1, $harga_2, $harga_3, NOW() );";

2) mysqli expects connection first then query, make sure you create mysqli connection.

mysqli_mutli_query($conni, $word) ;

3) for multiquery you must keep mysqli_mutli_query($conni,$word) outside for loop

.
.
.
.
      $word .= "INSERT INTO relation_mu_and_unit (id_drug, id_unit, priority, value, harga1, harga2, harga3, last_edit) VALUES  ( $id_drug,$id_unit, $i, $value, $harga_1, $harga_2, $harga_3, NOW() );";
 } // for loops ends here                                                                          
 mysqli_multi_query($conni,$word);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.