Forums

Save id from another table.

Yudhizth 25 Jun, 2015
Dear all,

I have a problem with save multiple data, I have two tables that have relations with id_permohonan.

1. tbl_t_permohonan
2. tbl_t_file_upload

I already success to save link of multiple upload, but it's not save id_permohonan as relation.

this is custom code after upload


<?php
if ($form->data["nama_file1"] !=""){
$form->data["namalist"]["0"]["nama_file"] = $form->files["nama_file1"]["link"];
}

if($form->data["nama_file2"] !=""){
$form->data["namalist"]["1"]["nama_file"] = $form->files["nama_file2"]["link"];
}
?>


That custom code only save link of file upload to tbl_t_file_upload. How to save id_permohonan to tbl_t_file_upload?
Yudhizth 25 Jun, 2015
Thanks for answer, but that is not the solution😟
GreyHead 25 Jun, 2015
Hi Yudhizth,

Do you have id_permohonan in the $form->data[''] array?

If so then you need something like:
<?php
if ( $form->data["nama_file1"] != "" ){
  $form->data["namalist"]["0"]["nama_file"] = $form->files["nama_file1"]["link"];
  $form->data["namalist"]["0"]["id_permohonan"] = $form->data['id_permohonan'];
}

if ( $form->data["nama_file2"] != "" ){
  $form->data["namalist"]["1"]["nama_file"] = $form->files["nama_file2"]["link"];
  $form->data["namalist"]["1"]["id_permohonan"] = $form->data['id_permohonan'];
}
?>

Bob
Yudhizth 25 Jun, 2015
Thanks Bob. It Works😀 I forget to put hidden field of id_permohonan.
This topic is locked and no more replies can be posted.