<?php
session_start();
require_once '../inc/const.php';
$_POST = eval('return ' . iconv('gb2312', 'utf-8', var_export($_POST, true)) . ';');$id         =getvar('id');
$name  =getvar('name');
$addr  =getvar('addr');
$httpurl =getvar('httpurl');
$tel =getvar('tel');
$mobile =getvar('mobile');
$fax  =getvar('fax');
$email  =getvar('email');
$qq  =getvar('qq');
$area  =getvar('area');
$industry =getvar('industry'); 
$rank =getvar("rank");$temp_fwnr = "";
$fwnr = $_POST['fwnr'];
for($i=0;$i<count($fwnr);$i++){
$service_start = "service_start".$fwnr[$i];
$service_end = "service_end".$fwnr[$i];
$service_content = "service_content".$fwnr[$i];
$temp_services = $fwnr[$i].",".$_POST[$service_start].",".$_POST[$service_end].",".$_POST[$service_content];
$temp_fwnr = empty($temp_fwnr) ? $temp_services : $temp_fwnr."|".$temp_services;

}if($act=='add'){
$record = array(
'name' =>$name,
'addr' =>$addr,
'httpurl' =>$httpurl,
'tel' =>$tel,
'mobile' =>$mobile,
'fax' =>$fax,
'email' =>$email,
'qq' =>$qq,
'area' =>$area,
'industry' =>$industry,
    'services' =>$temp_fwnr,
'rank' =>$rank,
'dateline' =>date("y-m-d H-i-s")
);
$id = $db->insert($GLOBALS[databasePrefix].'customer',$record);
//if (isset($_POST['id'])) {
     //echo "你的编号是:". $_POST['id'];
//}
if (var_dump($_POST['$id'])){
     echo "你的编号是:". $_POST['$id'];
}if (isset($_POST['name'])) {
     echo "你的名字是:". $_POST['name'];
}
}
?>
编号也就是ID号,  当前提交表单的id号输不出来。要怎么才可以输出来啊???????

解决方案 »

  1.   

    mysql_insert_id(); 获得上条插入数据的ID
      

  2.   

    $id=mysql_insert_id();这样就获得上条刚刚插入记录的ID值了,很简单的
      

  3.   

    <?php
    session_start();
    require_once '../inc/const.php';
    $_POST = eval('return ' . iconv('gb2312', 'utf-8', var_export($_POST, true)) . ';');$id         =getvar('id');
    $name         =getvar('name');
    $addr         =getvar('addr');
    $httpurl    =getvar('httpurl');
    $tel        =getvar('tel');
    $mobile        =getvar('mobile');
    $fax         =getvar('fax');
    $email         =getvar('email');
    $qq         =getvar('qq');
    $area         =getvar('area');
    $industry    =getvar('industry'); 
    $rank        =getvar("rank");$temp_fwnr = "";
    $fwnr = $_POST['fwnr'];
    for($i=0;$i<count($fwnr);$i++){
        $service_start = "service_start".$fwnr[$i];
        $service_end = "service_end".$fwnr[$i];
        $service_content = "service_content".$fwnr[$i];
        $temp_services = $fwnr[$i].",".$_POST[$service_start].",".$_POST[$service_end].",".$_POST[$service_content];
        $temp_fwnr = empty($temp_fwnr) ? $temp_services : $temp_fwnr."|".$temp_services;
        
    }if($act=='add'){
        $record = array(
            'name'        =>$name,
            'addr'        =>$addr,
            'httpurl'    =>$httpurl,
            'tel'        =>$tel,
            'mobile'    =>$mobile,
            'fax'        =>$fax,
            'email'        =>$email,
            'qq'        =>$qq,
            'area'        =>$area,
            'industry'    =>$industry,
            'services'    =>$temp_fwnr,
            'rank'        =>$rank,
            'dateline'    =>date("y-m-d H-i-s")
        );
        $db->insert($GLOBALS[databasePrefix].'customer',$record);
        $id = mysql_insert_id();
    //if (isset($_POST['id'])) {
         //echo "你的编号是:". $_POST['id'];
    //}
    if (var_dump($_POST['$id'])){
         echo "你的编号是:". $_POST['$id'];
    }if (isset($_POST['name'])) {
         echo "你的名字是:". $_POST['name'];
    }
    }
    ?>
      

  4.   

    按照楼上的方法  输出的是:NULL
      

  5.   

    把四楼的红字部分改为 $id=$db->lastInsertId();//最后一次插入记录的id号