Forum Moderators: coopster

Message Too Old, No Replies

Sequential Numbering at random

         

DontheCat

7:09 pm on Jul 7, 2012 (gmt 0)

10+ Year Member



I'm creating a site for our Alumni Assn... just need help with a quirky logic I've been stumped with.. these are the parameters

  • I've a Form through which the propsective Member submits his/her application
  • We will issue a Membership Card with a 16 Digit No with four digit grouping which will be
  • Year of Inception, Year of Graduation, Year of Membership and the last four digits will be the sequential membership Nos.
  • at this point, the subscription can be paid only thru Cheques or Online Funds Transfers and the authentication is manual
  • The Treasuuer monitors this and only after recpt of payment, the member is 'enabled' and listed on the site

    while the 1st three of the 4 digit groups are collected from the form, I'm not clear how to generate the sequentials. Initially, I thot I could use the auto-inceremented Record ID (unsigned-fill, length 4), but we are faced with a situation where some applicants could submit the application form and not make payments.... in which case the sequence of the numbers could be affected or gaps wil be there from unpaid applications

    an option I thought was, for the approved members, to store the membership No in a separate table and use the auto-genrated Record ID as a sequential number.... its a bit round-about and again its gonna be a problem once the membership crosess 9999 :-)

    I'm getting some more ideas which are equally ridiculous :-) ... so is there any way I can create a sequential number and store it another column in the main table itself on approval of the membership ?

    whew ! Thanks :-)
  • johnhh

    8:58 pm on Jul 7, 2012 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



    an idea for you ( we do the same sort of thing to generate a batch number )

    create field approved_member_number

    member gets approved

    query : select approved_member_number from tablename order by approved_member_number desc LIMIT 1

    gets the last highest number

    from the result (should be only one) check if no results if no results nextnumber=0 else nextnumber = approved_member_number +1

    query: update field approved_member_number with nextnumber

    you could also use count(approved_member_number) as totalmembers in the initial select query as that gets you the total number of members then nextnumber=totalmembers+1 this saves the check for 0 members

    Of course you could have a separate table for the numbers and do a join - easier to have in same table for reports etc

    Note I'm no PHP expert just thats how I do it

    Hope that helps .. hopefully you have only one user updating the approved members

    DontheCat

    10:35 am on Jul 8, 2012 (gmt 0)

    10+ Year Member



    Thanks johnhh :-)

    I'll try the 1st solution for a start...

    Cheers

    May the Power of Open Source be with you