0
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);
                    }
2
Contributors
2
Replies
13
Views
3 Years
Discussion Span
Last Post by urtrivedi
1

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);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.