Forums

This topic is locked

Marking something "full"

Posted 01 May 2002 23:18:11
1
has voted
01 May 2002 23:18:11 Mike Willis posted:
Trying to create a site that allows registration into a seminar. Any ideas on how I could set it up to recognize when the seminar is "full" and not allow any additional registrations?

Thanks!

Replies

Replied 01 May 2002 23:49:36
01 May 2002 23:49:36 Andrew Watson replied:
You could just use an Application Variable...
add 1 to it every time someone registers then once it reaches a certain number don't show them the registration form show them a 'seminar full' page...

ill try and get time to post code....

Cheers,

Leed

:: Son, im Thirty.... ::
Replied 02 May 2002 00:13:19
02 May 2002 00:13:19 Andrew Watson replied:
Stick this in JUST befor the INSERT command, if you use a standard UD insert behaviour put it Directly above the quoted out line that says

'execute the insert

but within the if statement that executes the insert


Heres the code snippet...

<pre id=code><font face=courier size=2 id=code>
If Application("avRegistrantCount" = "" Then
Application("avRegistrantCount" = 1
End If
If Application("avRegistrantCount" &gt; 0 Then
Application("avRegistrantCount" = Application("avRegistrantCount" + 1
End If
' If weve reached the maximum number of registrants then dont insert, goto the seminar full page
If Application("avRegistrantCount" = 50 Then
Response.Redirect("seminarfull.asp"
End If
</font id=code></pre id=code>

Or you could just count the records in your db and redirect/dontshow when it reaches a number..

Or you could...

or you could...

Hope this helps

Leed

:: Son, im Thirty.... ::
Replied 02 May 2002 14:19:14
02 May 2002 14:19:14 Mike Willis replied:
Leed,
Thanks for the great idea. I haven't worked much with application variables yet so this is very useful information.
Since we will actually have multiple seminars, something I should have put in my original posting, I'm thinking your second suggestion will be most appropriate. I'm not sure I understand how I could have an Insert page count the records in my table, seminar 1, seminar 2 etc., and then direct/redirect based upon that count. May I trouble you for a bit more detail on that suggestion?

Thanks for your time and effort!
Mike
Replied 03 May 2002 18:01:58
03 May 2002 18:01:58 Andrew Watson replied:
On your insert page, create a recorset that simply selects all the registrants for that seminar.

make sure that this appears ABOVE the Insert command on the page.

The new recordset code looks a bit like this...


<pre id=code><font face=courier size=2 id=code>
&lt;%
set rsRegistrants = Server.CreateObject("ADODB.Recordset"
rsRegistrants.ActiveConnection = MM_Test_STRING
rsRegistrants.Source = "SELECT * FROM tblRegistrants Where SeminarID = varThisSeminar"
rsRegistrants.CursorType = 0
rsRegistrants.CursorLocation = 2
rsRegistrants.LockType = 3
rsRegistrants.Open()
rsRegistrants_numRows = 0
%&gt;
</font id=code></pre id=code>

Alter this to read...(changes in <font color=red>red</font id=red>

<pre id=code><font face=courier size=2 id=code>
&lt;%
set rsRegistrants = Server.CreateObject("ADODB.Recordset"
rsRegistrants.ActiveConnection = MM_Test_STRING
rsRegistrants.Source = "SELECT * FROM tblRegistrants Where SeminarID = varThisSeminar"
rsRegistrants.CursorType = <font color=red>1</font id=red>
rsRegistrants.CursorLocation = 2
rsRegistrants.LockType = 3
rsRegistrants.Open()
rsRegistrants_numRows = 0
<font color=red>
If rsRegistrants.RecordCount &gt; 49 Then
Response.Redirect("SeminarFull.asp"
End If
</font id=red>
%&gt;
</font id=code></pre id=code>

As long as this is above your insert command, ie at the top of the page, then if there are **50** already registered then youll get whisked off to the seminar full page.


Hope this helps a little mate.

Cheers
Leed

:: Son, im Thirty.... ::

Edited by - leed on 03 May 2002 18:04:27
Replied 03 May 2002 20:50:01
03 May 2002 20:50:01 Mike Willis replied:
Thanks Leed! That looks like exactly the solution we need.

I appreciate your efforts on this "newby's" behalf.

Mike

Reply to this topic