Author |
Message |
Donovan
Client

Joined: Oct 07, 2003
Posts: 735
Location: Ohio
|
Posted:
Tue Mar 21, 2006 1:53 pm |
|
I am working on a gaming script to use for a league. I have a campaign with a map assigned to it with many territories assigned to the map.
Here is an idea.
I have a page I'm working on to update the map and change ownership, or "Army of Occupation" for each territory. Can't seem to figure this out.
I need an array to compare my Territory ID (tid) to occupiers (Allied, Axis or Neutral) for each territory. My php table will list all territories for that map and each record will have three radio buttons for me to select who occupies that territory.
Here is what I have so far.
Code:// Load Territories
$mapstatus = array();
$sql = "SELECT occupiers FROM " . $prefix . "_eto_territories WHERE mid ='$mid'";
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
$tid = $row["tid"];
$occupiers = stripslashes($row['occupiers']);
$mapstatus[] = array("tid" => $tid, "occupiers" => $occupiers);
}
foreach($mapstatus as $territory){
$tid = $territory["tid"];
$axischecked = "";
$alliedchecked = "";
$neutralchecked = "";
if ($mapstatus[$tid] == "Allies") { $alliedchecked = "CHECKED"; }
else if ($mapstatus[$tid] == "Axis") { $axischecked = "CHECKED"; }
else { $neutralchecked = "CHECKED"; }
echo "<td align=\"center\" bgcolor=\"#666666\" width=\"45%\">"
."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus\" $tid VALUE=\"Allies\" $alliedchecked><font color=\"#000000\"> Allies </INPUT>"
."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus\" $tid VALUE=\"Axis\" $axischecked><font color=\"#000000\"> Axis </INPUT>"
."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus\" $tid VALUE=\"Neutral\" $neutralchecked><font color=\"#000000\"> Neutral </INPUT>"
."</td>"
. "</tr>";
}
|
Here is a screenshot of what appears in my table.
I am not getting any records coming back cept for the first one.
Any help with this will be mucho appreciated. |
|
|
 |
 |
Donovan

|
Posted:
Tue Mar 21, 2006 7:20 pm |
|
Revised my code and now am getting the radio button to appear as they should.
Still not getting values to dislay for each radio button. And each set of radio buttons are not acting independent.
Code:// Load status of territories from database
$mid = intval($mid);
$sql = $db->sql_query("SELECT * FROM " . $prefix . "_eto_territories et JOIN " . $prefix . "_eto_maps em JOIN " . $prefix . "_eto_campaigns ec WHERE et.mid = em.mid AND ec.cid = em.cid AND ec.cid='$cid'");
while ( $row = $db->sql_fetchrow($sql) ) {
$tid = $territory["tid"];
$map_name = stripslashes($row['map_name']);
$t_name = stripslashes($row['t_name']);
$game_map = stripslashes($row['game_map']);
$occupiers = stripslashes($row["occupiers"]);
$mapstatus[] = array("tid" => $tid, "occupiers" => $occupiers);
foreach($mapstatus as $territory){
$axischecked = "";
$alliedchecked = "";
$neutralchecked = "";
if ($mapstatus[$tid] == "Allies") { $alliedchecked = "CHECKED"; }
else if ($mapstatus[$tid] == "Axis") { $axischecked = "CHECKED"; }
else { $neutralchecked = "CHECKED"; }
}
echo"<tr>"
."<td align=\"center\" width=\"25%\" bgcolor=\"#666666\"><font color=\"#000000\">$t_name</td>"
."<td align=\"center\" width=\"25%\" bgcolor=\"#666666\"><font color=\"#000000\">$game_map</td>"
."<td align=\"center\" bgcolor=\"#666666\" width=\"45%\">"
."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus $tid\" VALUE=\"Allies\" $alliedchecked><font color=\"#000000\"> Allies </INPUT>"
."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus $tid\" VALUE=\"Axis\" $axischecked><font color=\"#000000\"> Axis </INPUT>"
."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus $tid\" VALUE=\"Neutral\" $neutralchecked><font color=\"#000000\"> Neutral </INPUT>"
."</td>"
. "</tr>";
}
|
 |
|
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Wed Mar 22, 2006 5:46 am |
|
Wow, you are really getting fancy! Are you actually changing the map graphic too? Now, that would be an interesting challenge (no, i am not volunteering... ). |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
Donovan

|
Posted:
Wed Mar 22, 2006 8:22 am |
|
The map graphic is just photoshop. That will be taken care of by my GFX crew at the league. I just need to be able to update the occupiers each week in the table. Each territory has a value assigned to it like .125
At the end of the week after the matches are complete and the table updated I sum each side and then * by gow many territories they occupy.
For example if Allied owned
Amsterdam - .125
Arnhem - .15
Rotterdam - .15
Antwerp - .20
Ghent - .10
Eindhoven - .25
= .975 x number of territories = 5.85
At the end of the week the Allied division would earn 5.85 points
The same for Axis.
I need to press on with this but some of what I am trying to do is a little difficult, but offers me some good experience.
I do have some to spare if you have time to get involved. I could use some help and some experienced eyes on this project or it will take me forever.
Evaders is tied up at the moment. |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Wed Mar 22, 2006 9:50 pm |
|
Please post just the generated (html) code for the table with the radio buttons. |
|
|
|
 |
Donovan

|
Posted:
Wed Mar 22, 2006 10:13 pm |
|
You mean this?
Code:echo"<tr>"
."<td align=\"center\" width=\"25%\" bgcolor=\"#666666\"><font color=\"#000000\">$t_name</td>"
."<td align=\"center\" width=\"25%\" bgcolor=\"#666666\"><font color=\"#000000\">$game_map</td>"
."<td align=\"center\" bgcolor=\"#666666\" width=\"45%\">"
."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus $tid\" VALUE=\"Allies\" $alliedchecked><font color=\"#000000\"> Allies </INPUT>"
."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus $tid\" VALUE=\"Axis\" $axischecked><font color=\"#000000\"> Axis </INPUT>"
."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus $tid\" VALUE=\"Neutral\" $neutralchecked><font color=\"#000000\"> Neutral </INPUT>"
."</td>"
. "</tr>";
|
|
|
|
|
 |
Raven

|
Posted:
Wed Mar 22, 2006 10:24 pm |
|
No. I said the generated html code, not the php code
After it displays in your browser, do a view source and show me the way the html is being rendered by the browser. |
|
|
|
 |
Donovan

|
Posted:
Wed Mar 22, 2006 11:01 pm |
|
Code:<hr><center><font class="content"><b>Reports</b></font></center><br><br><form method="post" action="admin.php"><table border="2" cellpadding="2" align="center" cellspacing="0" style="border-collapse: collapse;" bgcolor="#000000" bordercolor="#111111" width="100%"><tr><td align="left" bgcolor="#666633"><b><font color="#000000">Battlefield Reports</font></b></td></tr><table border="0" width="100%" cellpadding="3"><tr><th width="20%">Territory Name</th><th width="20%">Game Map</th><th width="40%"><b>Army of Occupation</b></th></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Plymouth</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Portsmouth</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Dover</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Bristol</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">London</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Norwich</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Birmingham</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Cardiff</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Liverpool</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Sheffield</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Blackpool</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Grimsby</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Edinburgh</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Glasgow</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Newburgh</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Aberdeen</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Inverness</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Cork</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Galway</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Dublin</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Limerick</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Kilkenny</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Derry</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr><tr><td align="center" width="25%" bgcolor="#666666"><font color="#000000">Belfast</td><td align="center" width="25%" bgcolor="#666666"><font color="#000000"></td><td align="center" bgcolor="#666666" width="45%"><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Allies" ><font color="#000000"> Allies </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Axis" ><font color="#000000"> Axis </INPUT><INPUT TYPE="RADIO" NAME="mapstatus " VALUE="Neutral" CHECKED><font color="#000000"> Neutral </INPUT></td></tr></table><br><br><br><input type="hidden" name="op" value="MapSave"><input type="hidden" name="mid" value="0"><input type="submit" align="center" name="Submit" value="Update"></form> </td>
|
|
|
|
|
 |
Raven

|
Posted:
Wed Mar 22, 2006 11:18 pm |
|
If you are expecting each row to be independent of the other rows then you must chnge the NAME attribute for each set/row of radio buttons. You have them all named the same. |
|
|
|
 |
Donovan

|
Posted:
Thu Mar 23, 2006 2:24 pm |
|
That is how they are coming back, but I actually have it coded like this.
Code:."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus $tid\" VALUE=\"Allies\" $alliedchecked><font color=\"#000000\"> Allies </INPUT>"
."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus $tid\" VALUE=\"Axis\" $axischecked><font color=\"#000000\"> Axis </INPUT>"
."<INPUT TYPE=\"RADIO\" NAME=\"mapstatus $tid\" VALUE=\"Neutral\" $neutralchecked><font color=\"#000000\"> Neutral </INPUT>"
|
mapstatus $tid should be unique to each row...correct? |
|
|
|
 |
Raven

|
Posted:
Thu Mar 23, 2006 2:39 pm |
|
Don't know your code but you can't have a space inbetween there :wink
Try mapstatus$tid |
|
|
|
 |
|