saye ada masalah untuk dapatkan id dr table dan simpan ke dalam table lain.
ni coding yg saye tlh buat..
- Code:
/*
$id2 = mysql_insert_id ();
$sql = "SELECT submodule_id FROM t_submodule WHERE submodule_title = '$submodule' AND submodule_incharge = '$reportedby'";
if (true != ($result = mysql_query ( $sql, $con ))) {
die ( mysql_error () );
}
while ( true == ($row = mysql_fetch_array ( $result )) ) {
$submodule_id = $row['submodule_id'];
}
$sql = "INSERT t_map_issue (mi_recordid)
SELECT submodule_id
FROM t_submodule
WHERE submodule_id = '$id2'";
if (true != ($result = mysql_query ( $sql, $con ))) {
die ( mysql_error () );
}
*/
saye nak dapatkan id dr table t_submodule dan simpankan kedalam table t_map_issue.
user kene masuk dlm add issue dan user akan taip submodule title yg terdapat dalam table submodule
dan submodule ID akan dihantar ke t_map_issue.kirenye ada 3 table la yg berhubung kait.
dan 1 lagi..macam mane caranya juga untuk mendapatkan name table dan simpan ke dalam t_map_issue
contohnye bila user dah masukkan submodule title dan name table yg menyimpan submodule title
akan dimasukan ke t_map_issue
dan ini untuk full coding
- Code:
<?php
include_once 'library.php';
//filter all input from post
foreach ( $_POST as $key => $val ) {
$$key = trim ( addslashes ( $val ) );
}
$daterequested = eR_toYYYY_MM_DD ( $daterequested );
$sql = "INSERT INTO t_issues(
`isu_projid` ,
`isu_title` ,
`isu_desc` ,
`isu_status` ,
`isu_reportedby`)
VALUES ('$projid', '$title', '$desc', '$status', '$reportedby')";
if (true != ($result = mysql_query ( $sql, $con ))) {
die ( mysql_error () );
}
//get the ID of inserted requirement
$id = mysql_insert_id ();
$sql="INSERT t_map_issue( mi_issueid , mi_projid )
SELECT isu_id , isu_projid
FROM t_issues
WHERE isu_id = '$id'";
if (true != ($result = mysql_query ( $sql, $con ))) {
die ( mysql_error () );
}
$sql = "SELECT submodule_id FROM t_submodule WHERE submodule_title = '$submodule' AND submodule_incharge = '$reportedby'";
if (true != ($result = mysql_query ( $sql, $con ))) {
die ( mysql_error () );
}
while ( true == ($row = mysql_fetch_array ( $result )) ) {
$submodule_id = $row['submodule_id'];
}
$id2 = mysql_insert_id ();
$sql = "INSERT t_map_issue (mi_recordid)
SELECT submodule_id
FROM t_submodule
WHERE submodule_id = '$id2'";
if (true != ($result = mysql_query ( $sql, $con ))) {
die ( mysql_error () );
}
$sql = "SELECT func_id FROM t_function WHERE func_title ='$function'" ;
if (true != ($result = mysql_query ( $sql, $con))) {
die (mysql_error());
}
while (true == ($row = mysql_fetch_array ($result)) ) {
$func_id = $row['func_id'];
}
$id3= mysql_insert_id ();
$sql = "INSERT t_map_issue (mi_recordid)
SELECT func_id
FROM t_function
WHERE func_id = '$id3'";
if (true != ($result = mysql_query ( $sql, $con ))) {
die ( mysql_error () );
}
//redirect to the newly created project
header ( "Location: project_info.php?id=$projid&tabId=2" );
exit ();
?>
terima kasih