Author |
Message |
Donovan
Client

Joined: Oct 07, 2003
Posts: 735
Location: Ohio
|
Posted:
Wed Nov 09, 2005 9:13 am |
|
This thing keeps growing and growing...
What I am trying to do is create a combat record for the soldier profile page. You can see mine here at the bottom
http://www.3rd-infantry-division.net/modules.php?name=MILPACS&file=soldierprofile&uniqueid=6
I manually added those records into the table for display purposes.
What I want to do is create a combat record management page which I have here. I pull this from my vwar install that keeps track of all my matches.
I then have this next page where I list all the soldiers who are on active duty or on leave from the unit and may have participated in the match.
I then want to check each name of the solder who showed up for the match and played, then I click submit and it adds them to the milpacs_combat table. I need to link each check box with each uniqueid of the soldier.
Here is my code for the editwar.php
Code:<?php
/************************************************************************/
/* MILPACS (Military Personell and Classification System) */
/* Author::Donovan [3rd ID] */
/* Copyright (c) 2005 by Steven Donovan AKA Donovan [3rd ID] */
/* Email:: donovan@3rd-infantry-division.net
/* Homepage::http://www.3rd-infantry-division.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* */
/* This program is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* General Public License for more details. */
/* */
/* If you want a copy of the GNU General Public License write to the */
/* Free Software Foundation, Inc. */
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 */
/* USA */
/************************************************************************/
if (stristr($_SERVER['SCRIPT_NAME'], "editwar.php")) {
Header("Location: ../../index.php");
die();
}
if (!in_groups('1-10-23')) {
// Not authorized
echo "<META HTTP-EQUIV=\"refresh\" content=\".1;URL=modules.php?name=MILPACS&file=accessdenied\">";
echo "<a href=\"modules.php?name=MILPACS&file=accessdenied\">";
}
//finds the server's root directory
$index = 0;
@require_once("mainfile.php");
@include_once("header.php");
global $module_name, $db, $prefix;
$warid = $_GET['warid'];
OpenTable();
if ($op == "saveWar") {
// Validations go here
// If all validations passed, save and exit, otherwise, redisplay with errors
if ($warid == 0) {
$sql = "INSERT INTO " . $prefix . "_milpacs_combat (
warid,
uniqueid,
oppid,
) VALUES (
null,
$warid,
$uniqueid,
$oppid,
)";
} else {
$result = $db->sql_query ("UPDATE " . $prefix . "_milpacs_combat set warid = '$warid', uniqueid = '$uniqueid', oppid = '$oppid' WHERE warid = '$warid'");
}
if (!$result) {
echo("<p>Error adding Soldier!" . mysql_error() . "</p>");
}
else {
$result = $db->sql_query($sql);
echo "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=modules.php?name=$module_name&op=editwar&warid=$id\">";
exit();
}
}
$result1 = $db->sql_query("SELECT * FROM vwar v JOIN vwar_opponents vo JOIN vwar_matchtype vmt WHERE v.status = 1 AND v.oppid = vo.oppid AND warid = '$warid'");
if (!$result1) {
echo("<p>Error accessing war data!" . mysql_error() . "</p>");
}
while ($row = $db->sql_fetchrow($result1)) {
$date = date("F j, Y", $row["dateline"]);
$oppname = $row["oppname"];
$matchtype = $row["matchtypename"];
}
?>
<!--// Load members-->
<!--// Need to read the value of warstatus to load the checkboxes with checked or unchecked values. -->
<!--// Soldiers warstatus are either "1" which means they showed up for a match or "NULL" they did not show.-->
<!--// If box is checked then load a "1" into warstatus in the combat table.-->
<form name="editwar" action="modules.php?name=<?php echo $module_name ?>" method="POST">
<div align="center">
<label><H2>3rd ID War Report</H2></label>
<HR>
</div>
<br>
<p>
<strong>War Date: <?php echo $date ?> </strong>
<br>
<strong>Enemy Engaged: <?php echo $oppname ?> </strong>
<br>
<strong>Matchtype: <?php echo $matchtype ?> </strong>
<br>
<table border=0 width='100%' cellpadding='5'><tr>
<table border=0 width='100%' cellpadding='3'><tr><th width='5%'>Rank</th><th width='20%'>Name</th><th width='15%'><b>Position</b></th><th width='10%'>Present</th>
</tr>
</table>
<table border=0 width='100%' cellpadding='5'>
<?php
$sql = "SELECT mm.uniqueid, mm.unit_id, mm.position, mr.rank_abbr, mm.name FROM " . $prefix . "_milpacs_members mm JOIN " . $prefix . "_milpacs_ranks mr WHERE mm.rank_id = mr.rank_id AND mm.unit_id != '' AND mm.status IN ('Active','LOA') ORDER BY mm.rank_id ";
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
$id = $row["uniqueid"];
$rank = $row["rank_abbr"];
$name = $row["name"];
$position = $row["position"];
?>
<tr>
<td align="center" width="5%"><b><font color="#000000"><?php echo $rank ?></font></b>
</td>
<td align="center" width="20%"><b><font color="#000000"><?php echo $name ?></font></b>
</td>
<td align="center" width="15%"><b><font color="#000000"><?php echo $position ?></font></b>
</td>
<td align="center" width="10%"><input <?php if (!(strcmp($_POST['warstatus'],"Yes"))) {echo "checked";} ?> name="warstatus" type="checkbox" id="warstatus" value="Yes">
</td>
</tr>
<?php
}
?>
</table>
<input type="submit" align="center" name="Submit" value="Save"/>
<input type="hidden" name="op" value="saveWar"/>
<input type="hidden" name="warid" value="<?php echo $warid ?>"/>
</form>
<?php
CloseTable();
?>
|
The warid and uniqueid are concantenated and end up as the primary key of the combat table. I want to be able to initially add the members to the combat table or update the table to make changes. The editwar page will have to read from the table to see if this person is already listed and checked for this warid.
Any help is appreciated. |
|
|
 |
 |
Donovan

|
Posted:
Thu Nov 10, 2005 12:00 pm |
|
I also have an addmedal.php page I'm working on that has problems.
Code: <?php
/************************************************************************/
/* MILPACS (Military Personell and Classification System) */
/* Author::Donovan [3rd ID] */
/* Copyright (c) 2005 by Steven Donovan AKA Donovan [3rd ID] */
/* Email:: donovan@3rd-infantry-division.net
/* Homepage::http://www.3rd-infantry-division.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* */
/* This program is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* General Public License for more details. */
/* */
/* If you want a copy of the GNU General Public License write to the */
/* Free Software Foundation, Inc. */
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 */
/* USA */
/************************************************************************/
/*********************************************************/
/* Add Medal */
/*********************************************************/
if (stristr($_SERVER['SCRIPT_NAME'], "addmedal.php")) {
Header("Location: ../../../index.php");
die();
}
if (!in_groups(23)) {
// Not authorized
echo "<META HTTP-EQUIV=\"refresh\" content=\".1;URL=modules.php?name=MILPACS&file=accessdenied\">";
echo "<a href=\"modules.php?name=MILPACS&file=accessdenied\">";
}
//finds the server's root directory
$index = 0;
require_once("mainfile.php");
include_once("header.php");
global $module_name, $db, $prefix;
// Load Medal image
$urlofimages="$DOCUMENT_ROOT/modules/MILPACS/images/medals/";
$medalselecthtml = "<select name=\"medal\">";
$medalselecthtml .= "<option value=\"\">Select Medal Image</option>";
if ($handle=@opendir($urlofimages)) {
while ($imgfile = readdir($handle)) {
if ($imgfile != "." && $imgfile != ".." && $imgfile != "" && $imgfile != "index.html" && $imgfile != "WS_FTP.LOG" && $imgfile != "Thumbs.db") {
if ($imgfile==$award_image) {
$medalselecthtml .= "<option value =\"$imgfile\" selected>$imgfile</option>";
} else {
$medalselecthtml .= "<option value =\"$imgfile\" >$imgfile</option>";
}
}
}
@closedir($handle);
}
$medalselecthtml .= "</select></td>";
OpenTable();
if ($op == "addMedal") {
// Validations go here
// If all validations passed, save and exit, otherwise, redisplay with errors
$award_name = $_POST['award_name'];
$award_description = addslashes($_POST['award_description']);
$award_image = $_POST['award_image'];
$award_class = $_POST['award_class'];
//Insert the values into the database
$sql = "INSERT INTO " . $prefix . "_milpacs_awards (award_id, award_name, award_image, award_description, award_class)". "VALUES ('NULL','$award_name','$award_image','$award_description', '$award_class')";
}
//} else {
// //Update the values in the database
// $sql = "UPDATE " . $prefix . "_milpacs_awards set
// award_name = '$award_name',
// award_description = '$award_description',
// award_image = '$award_image',
// award_class = '$award_class'
// WHERE award_id = '$award_id'";
// }
// $result = $db->sql_query($sql);
// if (!$result) {
// echo("<p>Error performing query: " . mysql_error() . "</p>");
// exit();
// } else {
// echo "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=modules.php?name=MILPACS&file=award\">";
// }
?>
<form name="addmedal" action="modules.php?name=<?php echo $module_name ?>" method="POST">
<table width="100%" border="2" cellpadding="2" align ="center" cellspacing="0" style="border-collapse: collapse;" bgcolor="#000000" bordercolor="#111111">
<tr>
<td align="center" bgcolor="#777777">
<b><font color="#000000">3rd ID Medal <?php echo $award_name ?></font></b>
</td>
<tr>
<td align="left" bgcolor="#666633">
<b><font color="#000000">Medal Information</font></b>
</td>
</tr>
<table border=0 width='100%' cellpadding='3'><tr><th width='20%'>Medal Image</th><th width='30%'>Name of Medal</th><th width='20%'><b>Medal Details</b></th><th width='10%'><b>Medal Class</b></th></tr>
<tr>
<td align="center" size="20" bgcolor="#999999"> <?php echo $medalselecthtml ?>
</td>
<td align="center" bgcolor="#999999"><input type="text" size="40" name="name">
</td>
<td align="center" bgcolor="#999999"><textarea name="award_dt" cols="30" colspan="1" rows="3"> <?php echo$award_description ?></textarea>
</td>
<td align="center" bgcolor="#999999">
<select NAME="award_class">
<option VALUE="SB">Skill Badge
<option VALUE="UC">Unit Citiation
<option VALUE="IM">Individual Medal
</select>
</td>
</tr>
</table>
<br>
<br>
<hr>
<input type="hidden" name="op" value="addMedal">
<input type="hidden" name="award_id" value="<?php echo $award_id ?>"/>
<input type="submit" align="center" name="Submit" value="Add"/>
</form>
<?php
CloseTable();
include("footer.php");
?>
|
Things that need fixed:
if I click submit it says "Module file not found"
If I uncomments out that part the page does not display.
As always any help is appreciated. |
|
|
|
 |
evaders99
Former Moderator in Good Standing

Joined: Apr 30, 2004
Posts: 3221
|
Posted:
Thu Nov 10, 2005 3:57 pm |
|
Your input uses the name variable - that should not be used in any phpNuke script.
It is only for the phpNuke module name
Code:
<input type="text" size="40" name="name">
|
|
_________________ - Only registered users can see links on this board! Get registered or login! -
Need help? Only registered users can see links on this board! Get registered or login! |
|
|
 |
Donovan

|
Posted:
Fri Nov 11, 2005 2:15 pm |
|
Thanks for the tip. I always do that.
One page that is giving me trouble is the editmedal.php page.
Everytime I click on a link for a medal record to edit the data, it displays a blank fields on the page with no data for that record. I look in the database and the data for that record has been erased except for the award_id.
So when this page gets displayed it sets each field to blank
Code://Update the values in the medal table
if ($op = "saveMedal") {
$sql = "UPDATE " . $prefix . "_milpacs_awards SET award_name = '$award_name', award_description = '$award_description', award_image = '$award_image', award_class = '$award_class' WHERE award_id = '$id'";
$result = $db->sql_query($sql);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
}
|
To my knowledge saveMedal is not passed to this page. editMedal is what is passed.
My index.php handles the case statements for this.
Code:case "editMedal":
case "saveMedal":
@include_once("modules/$module_name/admin/editmedal.php");
|
So when this is clicked
Code:<td align="center" width="15%"><a href="modules.php?name=<?php echo $module_name ?>&op=editMedal&id=<?php echo $id ?>">Edit</a><p>
|
it opens up the editmedal page.
Here is the whole thing.
Code:<?php
/************************************************************************/
/* MILPACS (Military Personell and Classification System) */
/* Author::Donovan [3rd ID] */
/* Copyright (c) 2005 by Steven Donovan AKA Donovan [3rd ID] */
/* Email:: donovan@3rd-infantry-division.net
/* Homepage::http://www.3rd-infantry-division.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* */
/* This program is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* General Public License for more details. */
/* */
/* If you want a copy of the GNU General Public License write to the */
/* Free Software Foundation, Inc. */
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 */
/* USA */
/************************************************************************/
/*********************************************************/
/* Edit Medal */
/*********************************************************/
if (stristr($_SERVER['SCRIPT_NAME'], "editmedal.php")) {
Header("Location: ../../index.php");
die();
}
if (!in_groups(23)) {
// Not authorized
echo "<META HTTP-EQUIV=\"refresh\" content=\".1;URL=modules.php?name=MILPACS&file=accessdenied\">";
echo "<a href=\"modules.php?name=MILPACS&file=accessdenied\">";
}
//finds the server's root directory
$index = 0;
require_once("mainfile.php");
include_once("header.php");
global $module_name, $db, $prefix;
//Update the values in the medal table
if ($op = "saveMedal") {
$sql = "UPDATE " . $prefix . "_milpacs_awards SET award_name = '$award_name', award_description = '$award_description', award_image = '$award_image', award_class = '$award_class' WHERE award_id = '$id'";
$result = $db->sql_query($sql);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
}
// Display page with values from the awards table
if ($op != "saveMedal") {
$id = intval($_GET['id']);
$result = $db->sql_query("SELECT * FROM " . $prefix . "_milpacs_awards WHERE award_id ='$id'");
$info = $db->sql_fetchrow($result);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
} else {
$award_name = $info[award_name];
$award_image = $info[award_image];
$award_description = $info[award_description];
$award_class = $info[award_class];
}
}
// Load Medal image
$urlofimages="$DOCUMENT_ROOT/modules/MILPACS/images/medals/";
$medalselecthtml = "<select name=\"award_image\">";
$medalselecthtml .= "<option value=\"\">Select Medal Image</option>";
if ($handle=@opendir($urlofimages)) {
while ($imgfile = readdir($handle)) {
if ($imgfile != "." && $imgfile != ".." && $imgfile != "" && $imgfile != "index.html" && $imgfile != "WS_FTP.LOG" && $imgfile != "Thumbs.db") {
if ($imgfile==$award_image) {
$medalselecthtml .= "<option value =\"$imgfile\" selected>$imgfile</option>";
} else {
$medalselecthtml .= "<option value =\"$imgfile\" >$imgfile</option>";
}
}
}
@closedir($handle);
}
$medalselecthtml .= "</select></td>";
OpenTable();
?>
<!-- Display Form -->
<form name="editmedal" action="modules.php?name=<?php echo $module_name ?>" method="POST">
<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">3rd ID Medal <?php echo $award_name ?></font></b>
</td>
<tr>
<td align="left" bgcolor="#666633">
<b><font color="#000000">Medal Information</font></b>
</td>
</tr>
<table border=0 width='100%' cellpadding='3'><tr><th width='20%'>Medal Image</th><th width='30%'>Name of Medal</th><th width='20%'><b>Medal Details</b></th><th width='10%'><b>Medal Class</b></th></tr>
<tr>
<td align="center" size="20" bgcolor="#999999"><?php echo $medalselecthtml ?>
</td>
<td align="center" bgcolor="#999999"><input type="text" size="40" name="name" value="<?php echo $award_name ?>"/>
</td>
<td align="center" bgcolor="#999999"><textarea name="award_dt" cols="30" colspan="1" rows="3"><?php echo $award_description ?></textarea>
</td>
<td align="center" bgcolor="#999999"><input type="text" size="10" name="award_class" value="<?php echo $award_class ?>"/>
</td>
</tr>
</table>
<br>
<br>
<br>
<hr>
<input type="hidden" name="op" value="saveMedal"/>
<input type="hidden" name="id" value="<?php echo $id ?>"/>
<input type="submit" align="center" name="Submit" value="Update"/>
</form>
<?php
CloseTable();
@include_once("footer.php");
?>
|
|
|
|
|
 |
Donovan

|
Posted:
Sat Nov 12, 2005 4:42 pm |
|
Nevermind I fixed the last issue with the editmedal page.
Just one more thing.
In the medal table I have the following
award_name
award_description
award_image
award_class
Award class is either IM for "Individual medal", SB for "Skill badge", and UC for "Unit Citation".
The field only has IM, SB, or UC. I need a dropdown box in my editmedal page to show what is selected.
Here is my addmedal code which is simple enough.
Code:<select NAME="award_class">
<option VALUE="SB">Skill Badge
<option VALUE="UC">Unit Citiation
<option VALUE="IM">Individual Medal
</select>
|
I am drawing a blank here. How do I get the current value from my field displayed in a combo box for editing purposes?
Right now it is a text box.
Code:<td align="center" bgcolor="#999999"><input type="text" size="10" name="award_class" value="<?php echo $award_class ?>"/>
|
I could have something like
echo "<option value=\"$award_cd\">$award_class</option>";
$award_cd I guess would stand IM, UC, or SB. I don't see a need for award_cd in a separate table, but can't seem to figure thia out without it. |
|
|
|
 |
evaders99

|
Posted:
Sat Nov 19, 2005 1:37 am |
|
Here's how I would do it
Code:
$sb_select = $uc_select = $im_select = "";
if ($award_class == "SB") {
$sb_select = "selected";
} elseif ($award_class == "UC") {
$uc_select = "selected";
} elseif ($award_class == "IM") {
$im_select = "selected";
}
echo "<select NAME=\"award_class\">";
echo "<option VALUE=\"SB\" $sb_select>Skill Badge </option>";
echo "<option VALUE=\"UC\" $uc_select>Unit Citiation </option>";
echo "<option VALUE=\"IM\" $im_select>Individual Medal </option>";
echo "</select>";
|
That code is untested, but it should work |
|
|
|
 |
|