Username:
Password: Forgot?
Register
-/+
Shoutbox - History
sivart0 : we could put sivquest in this arcade :D
sivart0 : Moo
Kesha : Testing out Qutebrowser, works pretty good
Kesha : An HTML5 arcade would be cool, not sure how HTML5 games are distributed these days, wonder if there's a way to collect them for an arcade system?
Sean : finally got rid of the arcade link. Took a while to find where it was, lol
sivart0 : Hmmmm
sivart0 : Mobole test
momo : hi sean, i found a new php arcade and who adapted HTML game on it
Sean : I'm much better at it than I was back then for sure
sivart0 : anybody can write one, been done to death
 
Im stuck in a project
The 'we' factor
Posts: 182
Status: Offline
Group: Admin
Member: #3
Quote
So I'm making an event system. I have coded it all myself (except for a sql schema from sean).

Heres my table setup for MySQL (relevant to my question[s]):
users -> id | username | class | level | guild
events -> id | event_name | event_time
event_apps -> id | event_id | applicant_id



That is what I have so far.

I want to make it so that in the first image, when people apply, that it shows how many people have applied on the main list as well as if the logged in user has applied ("applied" blank) in the state column.

In the 2nd image, I have all the event details and a list underneath them that I would like to populate with all the users that have applied.

In the end, it should look something like:


So here's a checklist of things I need to do:
-Check how many people (members and 'randoms') that are signed up for an event then display it as number (Like the count() function.)
-Check to see if the user is applied for an event. If they are, display 'Applied' in the event list.
-List all of the people enrolled in a single event. (separate tables for members and randoms)
-Reoccurring events: Delete events from MySQL table after event is finished and make a new event for the next day. (if that makes sense)

Edited by: Matt , Dec 29th, 2012 @ 5:29 pm
Wow! Now THAT was insightful!
Now, I know you think you understand what I said...
But I'm not sure you realize you HEARD what I MEANT !
^ Top
I take JaxBoards seriously
Posts: 890
Status: Offline
Group: Admin
Member: #5
Quote
make sure event_id and applicant_id are indexed columns in event_apps and do something like:
SELECT * FROM 'event_apps' WHERE applicant_id='$userid' AND event_id='$eventid';
and if it returns something you know that particular user has applied to that particular event

listing all people in an event would be something like
SELECT * FROM 'event_apps' WHERE event_id='$eventid';
and that should return a bunch of rows with different applicant_id variables, which will tell you whos in that event

if you want separate sections for users and randoms youd just feed them into an array per each and call that array when you want to generate the table for them

reoccuring events you could probably just have the expiration date checked each time a page is called that gets events and if it's past that it'll delete that & create a new event. i don't know if this is the best way to do it tho lol
^ Top
The 'we' factor
Posts: 182
Status: Offline
Group: Admin
Member: #3
Quote
I got everything but the recurring events. That is kicking my ass right now because I cant figure out how to get a PHP date to see if its newer then a SQL date.
Wow! Now THAT was insightful!
Now, I know you think you understand what I said...
But I'm not sure you realize you HEARD what I MEANT !
^ Top
The 'we' factor
Posts: 182
Status: Offline
Group: Admin
Member: #3
Quote
annnnd got recurring events working :D

<? require('common.php'); $query = "SELECT                  id, event_name, event_date AS event_time, initiator, min_level, max_level               FROM                  DD_events           WHERE            event_date <= NOW()           "; try{     $stmt = $db->prepare($query);     $result = $stmt->execute(); } catch(PDOException $ex){     die("Failed to run query: " . $ex->getMessage()); } $chk = $stmt->fetchall(); //Loop through each row foreach ($chk as $chks) {   //Make some vars for later querys   $event_num = $chks['id'];   // If it is, create query to make the next event     $query = "INSERT INTO               DD_events (event_name, event_date, initiator, min_level, max_level)               VALUES               (:name, DATE_ADD(:event_date, INTERVAL 1 DAY), 0, :min_lvl, :max_lvl)           ";   $query_params = array(                    ':name' => $chks['event_name'],                    ':event_date' => $chks['event_time'],                    ':min_lvl' => $chks['min_level'],                    ':max_lvl' => $chks['max_level']                    );     try     {         // These two statements run the query against your database table.         $stmt = $db->prepare($query);         $stmt->execute($query_params);     }     catch(PDOException $ex)     {         die("Failed to run query: " . $ex->getMessage());     } //Delete applications from event   $query = "DELETE FROM               DD_event_apps             WHERE               event_id = $event_num";   try   {     // These two statements run the query against your database table.     $stmt = $db->prepare($query);     $stmt->execute($query_params);   }   catch(PDOException $ex)   {     die("Failed to run query: " . $ex->getMessage());   } // Delete event   $query = "DELETE FROM               DD_events             WHERE               id = $event_num";   try   {     // These two statements run the query against your database table.     $stmt = $db->prepare($query);     $stmt->execute($query_params);   }   catch(PDOException $ex)   {     die("Failed to run query: " . $ex->getMessage());   } }


It's not pretty and it will have to be modified in the future but it works for now.

Edited by: Matt , Jan 1st, 2013 @ 4:48 pm
Wow! Now THAT was insightful!
Now, I know you think you understand what I said...
But I'm not sure you realize you HEARD what I MEANT !
^ Top
The 'we' factor
Posts: 182
Status: Offline
Group: Admin
Member: #3
Quote
damnit sean, im hooked on sublime now <_<
Wow! Now THAT was insightful!
Now, I know you think you understand what I said...
But I'm not sure you realize you HEARD what I MEANT !
^ Top
-/+
Users Viewing This Topic