Why is it important that you "recycle" old PINs? This is most likely eating up the most time in your script execution. My suggestion would be to either A) just keep creating a new one and ignore ones when a child leaves or B) create a 2nd, much smaller table "available_pins" and when a child leaves, insert their former PIN into this table. Then upon executing the new student script, you check the available_pin table for rows > 0. If so, use the first one. If not, give them a new one. Good luck. -M -----Original Message----- From: Michael Cortes [mailto:cortesm@fortleboeuf.net] Sent: Monday, August 11, 2003 2:57 PM To: Ben Lake Cc: php-db@lists.php.net Subject: Re: Maximum execution time of 30 seconds exceeded I do have an auto_increment for the record id. But that is just a way for me 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 a 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 or 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 AUTO_INCREMENT field. 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 814.796.4795 -- 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