Re: PHP doubt
| From: | Girish Nath | Date: | Wed, 29 May 2002 13:59:20 +0000 |
| Subject: | Re: PHP doubt | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-99740@lists.php.net to get a copy of this message | ||
Hi
Make sure you have an auto_increment field in your table, do the insert
first, then use mysql_insert_id() to get the number of the last which you
can use for the customer number. See the notes at the following page:
http://www.php.net/manual/en/function.mysql-insert-id.php
Regards
Girish
--
www.girishnath.co.uk
"R" <r@jumac.com> wrote in message
news:000301c20772$9538d0b0$0a6da8c0@lgwezec83s94bn...
> Hey guys,
>
> I have written a program and being a newbie I dont know if this is good or
> will give me problems in the future, so will appreciate it if you could
just
> have a look at the function and give me your "esteemed opinion" ;-)
> This is just a snip from the program...its pretty easy so your guru's
should
> have no problem figuring it out.
>
>
> // connected to the database successfully and running this query:
> {
> mysql_query.........etc
> $r=select max(cno)+1 from customer;
> insert into customer values($r,'$name');
> }
> print("Your customer number is: $r");
>
> what do you think? And will this return the correct values if 2 people
> submitted the form at the same time?
>
>
> Cheers,
> -Ryan.
>