Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    42

    Unanswered: auto increment with PHP and MySQL

    Hi,

    Id like a little advise if possible. I have a MySQL database. Say I have job_id as an auto increment. Im trying to access this database via a the net using PHP. What I would like is when somebody adds a record the next number on job_id would automatically be set.

    I know that in oracle you select next.val from dual or something like that with the PHP. Im not sure how to go about this using PHP and MySQL. Im rather new to both.

    Any advise or direction would be most appreciated.

    Thanks

  2. #2
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    Could you be little more clear with this
    "What I would like is when somebody adds a record the next number on job_id would automatically be set. "
    Where do u want to set the next job_id?
    If you want to run another query after this and want to store the next no in it then you could use mysql_insert_id() this will return the value if the auto incremented value is generated for the previous query.. You can add '1' to it to ge the next no .
    If this is not ur solution please made the above (the quoted one) statment little more clear
    Regards
    Rajesh

  3. #3
    Join Date
    Mar 2004
    Posts
    42
    Cheers for the advise. Ive sorted it cheers. You were on the right lines.


    Jon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •