PortalParts.com Site

 Forum Index > Geeklog > Misc Projects New Topic Post Reply
 glEventMgr - number of attendees?
 |  Printable Version
Blaine
 August 20 2007 21:17 PM  
Forum Admin
Admin

Status: offline

Registered: 03/01/02
Posts: 3576

Uh, try this:

PHP Formatted Code

$query = DB_query("SELECT SUM(attendee.quantity) FROM {$_TABLES['reg_attendees']} attendee WHERE attendee.eid='$eid'");
list ($numAttendees) = DB_fetchArray($query);
 

You executed the query but then need to fetch the result - in this case 1 field and should be just one row in the resultset. You may also need to do a GROUP BY in the clause for the SQL SUM function to work. Using phpMyAdmin to test out your query will help refine the needed SQL.


Please consider contributing to support my efforts ..
 
Profile Email Website PM
Quote
macwunder
 August 20 2007 21:40 PM  
Forum Junior
Junior

Status: offline

Registered: 08/12/07
Posts: 8

That worked the treat! even with two events listed. I changed the variable names a bit. I didn't want to blow $query in case it's used again in the loop:

PHP Formatted Code
$query1 = DB_query("SELECT SUM(attendee.quantity) FROM {$_TABLES['reg_attendees']} attendee WHERE attendee.eid='$eid'");
list ($registered) = DB_fetchArray($query1);


Let me see if I can push it out to the compare.

Thanks, Blaine. Are you interested in the modified code? I think Dazzy said he was interested. You should decide.


 
Profile Email PM
Quote
Blaine
 August 20 2007 21:56 PM  
Forum Admin
Admin

Status: offline

Registered: 03/01/02
Posts: 3576

Sure, I think it's a good idea - send it along :)


Please consider contributing to support my efforts ..
 
Profile Email Website PM
Quote
macwunder
 August 20 2007 22:11 PM  
Forum Junior
Junior

Status: offline

Registered: 08/12/07
Posts: 8

I also swapped the order of the if, elseif, else statements to put up the Un-register Me link before saying registration closed, so people might unregister and make room for others when the max is hit.

I'll PM you a link to download my mods. I think I've made all the changes required to make it an installable plugin.

Jeff


 
Profile Email PM
Quote
Content generated in: 0.20 seconds
New Topic Post Reply



 All times are CDT. The time is now 05:12 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content