if (trim($_POST['save'])!=""){
$strsql="select max(type_id) as type_id from t_foodstype";
$re=mysql_query($strsql) or die(error());
$row=mysql_fetch_array($re);
$id=$row["type_id"]+1;
$type_name=$_POST['txt_type_name'];
$sql="insert into t_foodstype set type_id='".$id."', type_name='".trim($type_name)."' ";
//echo $sql;
mysql_query($sql)or die(mysql_error());
}
<script type="text/javascript">
function chknull(e){
if (e.txt_type_name.value=="") {
alert( "Please enter date!");
e.txt_type_name.focus();
return false;
}
/*window.opener.location.reload(true); */
window.close(); <- ตรงนี้แหละครับต้นตอของปัญหา
}
</script>
ยังไม่วิ่งเข้าเงื่อนไขการบันทึกก็ถูปปิดลงไปก่อน
Code (PHP)
if (trim($_POST['save'])!=""){
$strsql="select max(type_id) as type_id from t_foodstype";
$re=mysql_query($strsql) or die(error());
$row=mysql_fetch_array($re);
$id=$row["type_id"]+1;
$type_name=$_POST['txt_type_name'];
$sql="insert into t_foodstype set type_id='".$id."', type_name='".trim($type_name)."' ";
//echo $sql;
mysql_query($sql)or die(mysql_error());
}