Donovan Posted November 19, 2006 Share Posted November 19, 2006 I use PHPNuke and am trying to create a module for use to enhance or as an addon to my league/ladder module.I am trying to create a page in a PHPNuke module that will allow me to add points to any team I choose. I run a game league based off of Call of Duty 2 and am trying to modify the way the typical ladder works. We play the game and run the league to benefit the Tactical Realism crown and run a strategic mapeto-league.comI want to incorporate some of the game feature in the other game called Company of Heros. This game has a map as well but has several strategic points spread across the map. Once you capture these points they benefit your side by adding Fuel, Manpower, and Munition points.Each territory would have one or the other types of points (Fuel, Manpower, Munitions). These accumulate as the ladder progresses and territories are captured. I want to allow a Commander to login and reenforce any team with whichever type of point they choose. The type of points is a drop down (Fuel, Manpower, Munitions) then 5 radio buttons with 1,2,3,4,5 for number of points they are reenforcing with.Such as:[code=php:0]// Get values to populate combo box $result = $db->sql_query("SELECT rp_id, rpoint_class FROM " . $prefix . "_eto_rpoints");while ( $row = $db->sql_fetchrow($result) ) { $rpclass = $row["rpoint_class"]; $rp_id = $row["rp_id"]; echo "<option value=\"$rp_id\">$rpclass</option>"; }?> </select> </td> <td align="left" valign="middle" bgcolor="#666666">Points:<br> <input type="radio" name="points" checked value="1"> 1 Point<br> <input type="radio" name="points" value="2"> 2 Points<br> <input type="radio" name="points" value="3"> 3 Points<br> <input type="radio" name="points" value="4"> 4 Points<br> <input type="radio" name="points" value="5"> 5 Points<br> </td>[/code] My question is how do I design the MySQL table and php page to accomplish this?Table name eto_pointsrp_id rpoint_class 1 Fuel 2 Munitions 3 ManpwerHere is a screenshot.[img]http://www.eto-league.com/modules/Campaign/images/screenshots/reenforce.gif[/img]In the team table I have 3 separate fields for each type of points.fuel_ptmanpower_ptmunition_ptHow do I add to these fields based off what they choose in the dropdown?Do I use a large case statment? I have been thinking about this for a day or two and am coming up blank.I think I would also need some sort of lookup table to insert the team_id, rp_id, and maybe a currentdate so I could keep track of this info.Below is a rough draft of my Reenforce.php page[code=php:0] <?php/************************************************************************* ETO Campaign Mod* By: Donovan [3rd ID] * http://www.eto-league-com* Copyright © 2006 by ETO* License: GNU/GPL************************************************************************//*********************************************************//* Reenforce *//*********************************************************/if (!defined('MODULE_FILE')) { die ("You can't access this file directly..."); } define('INDEX_FILE', true);$index = 0;require_once("mainfile.php");$module_name = basename(dirname(__FILE__));get_lang($module_name); @include_once("header.php");global $prefix, $db, $module_name;OpenTable();$team_id = $_GET['team_id'];$sql = "SELECT name FROM " . $prefix . "_tc_teams WHERE team_id ='$team_id'";$result = $db->sql_query($sql);$info = $db->sql_fetchrow($result); if (!$result) { echo("<p>Error performing query: " . mysql_error() . "</p>"); exit(); } else { $unitname = $info['name']; }if($op=="Reenforce") { $rp_id = intval($_POST['rp_id']); $rpoint_dt = $_POST['rpoint_dt']; $r_points = intval($_POST['r_points']); $team_id = intval($_POST['team_id']); //Insert the values into the correct database with the right fields $result = $db->sql_query ("INSERT INTO " . $prefix . "_eto_rpoints_lkup (pid, rp_id, rpoint_dt, team_id, r_points)". "VALUES ('NULL','$rp_id','CURRENT_TIMESTAMP()','$team_id','$r_points')"); $result = $db->sql_query($sql); echo "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=modules.php?name=Campaign&file=Reenforce&team_id=$team_id\">";if (!$result) { echo("<p>Error performing query: " . mysql_error() . "</p>");}} ?> <table border="2" cellpadding="2" align="center" cellspacing="0" style="border-collapse: collapse;" bgcolor="#000000" bordercolor="#111111" width="100%"> <tr> <td align="center" bgcolor="#777777"> <b><font color="#000000">Resource Points for the <?php echo $unitname ?> </font></b> </td> <tr> <td align="left" bgcolor="#666633"> <b><font color="#000000">Add Points</font></b> </td> </tr><table border=0 width="100%" cellpadding="3"> <tr> <th width="20%">Type of Reenforcment</th> <th width="20%">Point Value</th> </tr> <tr> <td align="center" bgcolor="#666666"> <select name="rp_id" size="1"> <option value="">--- Select Action ---</option><?php// Get values to populate combo box $result = $db->sql_query("SELECT rp_id, rpoint_class FROM " . $prefix . "_eto_rpoints");while ( $row = $db->sql_fetchrow($result) ) { $rpclass = $row["rpoint_class"]; $rp_id = $row["rp_id"]; echo "<option value=\"$rp_id\">$rpclass</option>"; }?> </select> </td> <td align="left" valign="middle" bgcolor="#666666">Points:<br> <input type="radio" name="points" checked value="1"> 1 Point<br> <input type="radio" name="points" value="2"> 2 Points<br> <input type="radio" name="points" value="3"> 3 Points<br> <input type="radio" name="points" value="4"> 4 Points<br> <input type="radio" name="points" value="5"> 5 Points<br> </td> </tr></table><br><input type="hidden" name="op" value="Reenforce"/><input type="hidden" name="pid" value="<?php echo $pid ?>"/><input type="submit" align="center" name="Submit" value="Add"/></form><br><br><?phpCloseTable();OpenTable();//$result = $db->sql_query("SELECT * FROM " . $prefix . "_eto_rpoints_lkup lkup JOIN " . $prefix . "_tc_teams WHERE ='$id'");//$info = $db->sql_fetchrow($result);//if (!$result) {// echo("<p>Error performing query: " . mysql_error() . "</p>");// exit();//}echo "<table border=\"2\" cellpadding=\"2\" align =\"center\" cellspacing=\"0\" style=\"border-collapse: collapse\" bgcolor=\"#000000\" bordercolor=\"#111111\" width=\"100%\"><tr>" . " <td align=\"center\" bgcolor=\"#777777\">" . " <b><font color=\"#000000\">Record of Combat Orders</font></b>" . " </td>" . " <tr>" . " <td align=\"left\" bgcolor=\"#666633\">" . " <b><font color=\"#000000\">Resource points added or removed.</font></b>" . " </td>" . " </tr>";echo "<table border=0 width='100%' cellpadding='3'><tr><th width='25%'>Type</th><th width='20%'>Date of Action</th><th width='20%'>Resource Points Added</th><th width='35%'><b>Details</b></th></tr>"; $id = $_GET['team_id']; $sql = "SELECT * FROM " . $prefix . "_eto_rpoints_lkup lkup, " . $prefix . "_eto_rpoints rp WHERE lkup.team_id ='$id' AND rp.rp_id = lkup.rp_id ORDER BY lkup.rpoint_dt DESC";$result = $db->sql_query($sql);while ( $row = $db->sql_fetchrow($result) ) { $class = $row["rpoint_class"]; $point_id = $row["rp_id"]; $date = $row["rpoint_dt"]; $pdetails = $row["rpoint_details"]; $points = $row["r_points"]; list($Year,$Month,$Day) = split('-',$date); $formatpointdate = date("F j, Y",mktime(12,0,0,$Month,$Day,$Year)); echo " <tr>"; echo " <td align=\"center\" bgcolor=\"#666666\">$class</td>"; echo " <td align=\"center\" bgcolor=\"#666666\">$formatpointdate</td>"; echo " <td align=\"center\" bgcolor=\"#666666\">$points</td>"; echo " <td align=\"center\" bgcolor=\"#666666\">$pdetails</td>"; echo " </tr>";}echo "</table>";echo "<br>";CloseTable();include("footer.php");?>[/code] Quote Link to comment 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.