Hi Xnuiem, sorry to trouble once again.
after completing the earlier issue, i was wondering if the same method of the code can be used if i am do update the data?
i.e. after retrieving from the database into a form i created, allow user to edit on the form and update the database.
Code:
list($C_insert) = mysql_fetch_row(mysql_query("select C_id
from C where C_label = '$devC' limit 1"));
list($B_insert) = mysql_fetch_row(mysql_query("select B_id
from B where B_type = '$devB' limit 1"));
list($D_insert) = mysql_fetch_row(mysql_query("select D_id
from D where D_model = '$devD' limit 1"));
list($E_insert) = mysql_fetch_row(mysql_query("select E_id from E where E_num = '$val_E_num' and E_type = '$val_E_type'
and E_partno = 'val_E_partno' $ limit 1"));
if ($E_insert == '')
{
$E_insert = "INSERT INTO E (E_num, E_type, E_partno)
VALUES ('$val_E_num', '$val_E_type', '$val_E_partno' )";
$result = mysql_query($E_insert) or die (mysql_error());
$E_insert = mysql_insert_id() or die (mysql_error());
}
list($S_insert) = mysql_fetch_row(mysql_query("select S_id from S where S_site = '$val_S_site' and S_name = '$val_S_name' limit 1"));
if ($S_insert == '')
{
$S_insert = "INSERT INTO S (S_site, S_name)
VALUES ('$val_S_site', '$val_S_name')";
$result = mysql_query($S_insert) or die (mysql_error());
$S_insert = mysql_insert_id() or die (mysql_error());
}
$sql = "UPDATE dev
SET dev_num = '$devnum',
dev_C = '$C_insert',
dev_B = '$B_insert',
dev_D= '$D_insert',
dev_E = '$E_insert',
dev_S = '$S_insert',
dev_dibid = '$val_dib',
dev_remark = '$val_remark'
WHERE
dev_id = '$getid'
LIMIT 1 ";
mysql_query($sql) or die ("ERROR!" .mysql_error());