I'd agree with what someone else said about keeping a separate table full of
possible pin numbers.

Fill it with all of the pin numbers to begin with, add in a "building" or
"department" row so you know what sequences go with what building, etc.

Then, to get a pin number for someone, you can just:


Where the ... determines the correct building, department, whatever.

If you end up using that pin, delete it from the table. When the student
leaves, insert it back into the table.

---John Holmes...

----- Original Message ----- 
From: "Michael Cortes" <[EMAIL PROTECTED]>
To: "Ben Lake" <[EMAIL PROTECTED]>
Sent: Monday, August 11, 2003 2:56 PM
Subject: Re: [PHP-DB] Maximum execution time of 30 seconds exceeded

I do have an auto_increment for the record id.  But that is just a way for
to uniquely id the record.  Student numbers, barcodes, etc can change.

The reason I am using the do/while loop is:   Every student is getting a
4digit pin for library, cafeteria and network access.  It has to be unique
and we have been assigning a different range of numbers per building/grade.
There are various procedural reasons for this.  I have verified that I am
identifying the new student correctly and going into the do/while loop with
variable that holds the correct starting number for the appropriate pin
range.  It's then just a matter of trying consecutive numbers till I find an
available pin.  The pin may be available because a student left the school
because it's next available at the end of the line.

Anyway, I was not aware I could pick and choose my ranges in an

I appreciate any thoughts you may have.  Thanks.

On Monday 11 August 2003 02:41 pm, you wrote:
> Why don't you use an AUTO_INCREMENT field in your table to define a
> unique number?
> Ben
> -----Original Message-----
> I had a do while loop such as
> do {
> mysql_query ($qupdate, $link);
> $rslterror=mysql_error($link);
> $number++
> } while ($rslterror!=null);
> Anyway, I fixed my dumb mistake.  If anyone would like to help me with a
> better one, maybe you can tell me if I am doing my do while correctly.
> It's only running through once, not getting a succesful insert  and
> dropping out.
> Thanks


Michael Cortes
Fort LeBoeuf School District
34 East Ninth Street
PO Box 810
Waterford PA 16441-0810

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to