Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Assigning a Record Number/Ticket number

Guest
Mar 20, 2009 Mar 20, 2009

Copy link to clipboard

Copied

Hello ,

I am developing a web application.I am trying to build a functionality where user will be able to insert a new record in a table in backend MySql DB.When inserting a new ticket/record, I want the system to assign a record number/ticket number which will be unique to that particular ticket.I am trying to concatenate the company id of the user and the Id( Index) column, so that I get a unique ticket number.The problem is that the Id is generated when the record is inserted, so I cannot reference it in my insert query.Is there a way I can get my way around it and generate a unique ticket number of the format ABC12 ( ABC: Company_Id and 12: picked from ID column as of now.)?

TOPICS
Server side applications

Views

511
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 20, 2009 Mar 20, 2009

Copy link to clipboard

Copied

abhidev wrote:
> The problem is that the Id is generated when the
> record is inserted, so I cannot reference it in my insert query.

You can run mysql_insert_id() immediately after the insert query to get
the ID. Then use an update query to add the ticket number.

http://docs.php.net/manual/en/function.mysql-insert-id.php

--
David Powers
Adobe Community Expert, Dreamweaver
http://foundationphp.com

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 23, 2009 Mar 23, 2009

Copy link to clipboard

Copied

LATEST
Thanks a lot David!!!

Its working perfectly fine.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines