Page 1 of 1

get auto_increment id

Posted: Fri May 06, 2005 9:57 am
by shiznatix
there is a auto incrementing id in this table. the id is called working_expierence_id. heres my query

Code: Select all

$query = '
            INSERT INTO
                mdl_cv_working_experience
                    (company_name, beginning_date, end_date,
                    fk_working_experiences_id,
                    fk_dd_job_category_id, fk_dd_occupation_id,
                    fk_dd_position_id, fk_dd_industry_id,
                    fk_dd_company_type, fk_dd_company_size)
            VALUES
                    ("'.$_POST[edit][company_name].'", "'.begin_date.'",
                    "'.end_date.'", "'.$work_exps_id[0].'", "'.$_POST[job_category].'",
                    "'.$_POST[occupation].'",
                    "'.$_POST[position].'", "'.$_POST[industry].'",
                    "'.$_POST[company_type].'", "'.$_POST[company_size].'")
        ';
inside that query i need to retreive the id that it makes when inserting those values and whatnot. how do i do that? i can not have a seperate query to get the id.

Posted: Fri May 06, 2005 10:02 am
by onion2k
If you're using mySQL, just use something like $id = mysql_insert_id(); immediately after the insert.

Posted: Fri May 06, 2005 11:19 am
by shiznatix
many thanks