Medicine Posted June 20, 2012 Share Posted June 20, 2012 I'm creating a KIND OF fantasy betting script, but instead of money, users get points, and are ranked by how many points. It's based on MMA so the betting would go like so. . . Pick the Winner of the fight Pick the Method of victory Pick the Round they will win in. So, I can code the basic stuff i.e users picking the above results, but I don't know how to code so I (Admin) can add results, then when results are added, users that pick correct, Gain points. ANY Help would be appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/ Share on other sites More sharing options...
RobertP Posted June 20, 2012 Share Posted June 20, 2012 you will need to create a user management system, with different access levels. you will need to create a page for members to view the up coming fights. a page with information about each fight. a page where they can vote bet on a fight. .. and thats just to start. Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355309 Share on other sites More sharing options...
Bradley99 Posted June 20, 2012 Share Posted June 20, 2012 I've created a page for the upcoming events, fights, info on fights & and a page where they can choose the outcome etc. I just need to create the part where I can enter the winner, what round & method, and with doing that, the people who predicted it correctly gain X amount of points. So I have for example. . . Anderson Silva Vs Chael Sonnen To Win: Chael Sonnen (Radio Button) Anderson SIlva (Radio Button) Method: KO (Radio Button) TKO (Radio Button) Submission (Radio Button) Decision (Radio Button) Round: 1 (Radio Button) 2 (Radio Button) 3 (Radio Button) 4 (Radio Button) 5 (Radio Button) When a user picks each of the above, it sends it to the picks in the database. I just need to create what I stated above now. (I am same person, Just managed to find my main account on here). Thanks BTW. Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355310 Share on other sites More sharing options...
Bradley99 Posted June 20, 2012 Share Posted June 20, 2012 Just so it's clear, I have EVERYTHING apart from what I've requested. I have homepage, Users register/login, through to main page, Then menu for Upcoming events, Fights, Fights Info, Your Picks etc. I just need the back-end coding for when users select their picks, I need to be able to (after the event) enter the results and when the results are entered and final, whomever chose the correct results, gains points. Thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355340 Share on other sites More sharing options...
Skewled Posted June 20, 2012 Share Posted June 20, 2012 Robert answered your question, it's really the way to go for this type of setup. If you are asking for someone to write all the scripts for your back-end administration area then you'd have to look at the freelance section of the forum. If you have some code you've come up with and are looking for help fixing it then we'd all be pretty happy to help you out. Setup a field in your database for admin flag 0 or 1. Make each script check it or store it in a session for a quick check, encode it or do whatever to secure it. Then make your forms and db features for altering events. Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355344 Share on other sites More sharing options...
Bradley99 Posted June 20, 2012 Share Posted June 20, 2012 I've already done what Robert suggested. I have back-end Admin, I just don't know what the best way to go about coding it so that when I enter the results of events, it adds points to whomever chose correct fighters etc. I'm not asking for code, just the best WAY. Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355349 Share on other sites More sharing options...
Bradley99 Posted June 20, 2012 Share Posted June 20, 2012 So in my DB, I have Events table, Which has Name - Fight 1 - Fight 2. . . and so on. When I enter the results back-end, would it be something like "if $userpick = $winner UPDATE $userpoints+10" Not clean code obviously, just along the lines. . Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355351 Share on other sites More sharing options...
Skewled Posted June 20, 2012 Share Posted June 20, 2012 yeah you could throw them in a foreach and update all the records that resulted in the correct choice Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355353 Share on other sites More sharing options...
Bradley99 Posted June 20, 2012 Share Posted June 20, 2012 I think maybe I'll change DB so that the events table is more like. . Username - Pick 1 - Pick1 Method - Pick1 Round - Pick1 Winner - Pick1 W Method - Pick1 W Method I wanted to keep the DB not massive though. I'm sure I'll figure it. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355356 Share on other sites More sharing options...
Skewled Posted June 20, 2012 Share Posted June 20, 2012 <?php // Connect to the database and establish values for Aurtua bonus. $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // $increment=10; $fields = Array("points"); // foreach ($fields as $fld) { $query = "update table set $fld=($fld+$increment) where winner = 'fighter1'"; mysqli_query($dbc, $query) or die("cannot execute: ". mysql_error()); echo "completed"; } mysqli_close($dbc); ?> You'd have to enter your connection information, adjust the table name and the winner to match the correct name, but that's workable. You could also alter it to take input from a field from a form that you'd have access to, and just type the winner name and run the script to step over all the fields and reward the winners. Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355357 Share on other sites More sharing options...
Mahngiel Posted June 20, 2012 Share Posted June 20, 2012 I've already done what Robert suggested. I have back-end Admin, I just don't know what the best way to go about coding it so that when I enter the results of events, it adds points to whomever chose correct fighters etc. I'm not asking for code, just the best WAY. You're going to need several tables here. Table 1: Users table. This identifies each of your users and what makes them individual Table 2: Match table. This is where you create matches for your users to 'bet' on. This table will have things like a unique id, the opponents, date/time, and whatever options the users can bet against. Based on this table, your users are able to opt for their choices. These choices are stored in the next table. Table 3: Betting table. This correlates a user's id with a match id and their bet. With all of that information, you will write your functions to run the results through when you go back and finalize the match. Based on the function's results, you can update the user's table with their points gained / lossed. Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355358 Share on other sites More sharing options...
Bradley99 Posted June 20, 2012 Share Posted June 20, 2012 I think that's what I was missing, the Betting table, I have User table & Match (Event) table, I think I just need to add the Betting table! I'm just struggling on how to layout the table in terms of picks, because for each event there is 10+ picks. I didn't wanna over complicate things. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355360 Share on other sites More sharing options...
Skewled Posted June 20, 2012 Share Posted June 20, 2012 You could enumerate the field to have multiple picks for a given event.... *Runs to bed* I'm too tired to be here, and let a lone try to be helpful! lol! Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355363 Share on other sites More sharing options...
Mahngiel Posted June 20, 2012 Share Posted June 20, 2012 I think that's what I was missing, the Betting table, I have User table & Match (Event) table, I think I just need to add the Betting table! I'm just struggling on how to layout the table in terms of picks, because for each event there is 10+ picks. I didn't wanna over complicate things. Thanks Based on this: Anderson Silva Vs Chael Sonnen To Win: Chael Sonnen (Radio Button) Anderson SIlva (Radio Button) Method: KO (Radio Button) TKO (Radio Button) Submission (Radio Button) Decision (Radio Button) Round: 1 (Radio Button) 2 (Radio Button) 3 (Radio Button) 4 (Radio Button) 5 (Radio Button) If this betting formula is a static method, then you would have a fairly simple table. Betting Table | bet_id | match_id | user_id | fighter_id | method | round Betting Form <input type=hidden value=1 name=match_id /> <input type=radio name=fighter value=1>Sonnen <input type=radio name=fighter value=2>Silva <select name=method><option value=1>KO</option><option value=2>TKO</option> ... <input type=text name=round placeholder=round /> So user 'John' with id 12 would select: Silva (duh!), TKO, 3 Betting Table | bet_id | match_id | user_id | fighter_id | method | round | 1 | 1 | 12 | 2 | 2 | 3 Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355366 Share on other sites More sharing options...
Bradley99 Posted June 20, 2012 Share Posted June 20, 2012 Thanks Mahngiel! That's what I'm looking (was looking) for!! I'm gonna get it done tomorrow I'll let you know how I get on and what method I use! Thanks for all the help guys! Quote Link to comment https://forums.phpfreaks.com/topic/264467-point-scoring-system/#findComment-1355369 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.