PHP Web Host - Quality Web Hosting For All PHP Applications Just Great Software
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
Donovan
Client


Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Fri Dec 16, 2005 9:32 am Reply with quote Back to top

Here is the thing...

I had a page that did edits and adds to a table and now I am trying to find away to split this into separate pages.

Here is the original drillreport cleaned up a bit.

Code:
<?php
/************************************************************************/
/* MILPACS (Military Personell and Classification System)               */
/* Drill Report page
/************************************************************               

if (stristr($_SERVER['SCRIPT_NAME'], "drillreport.php")) {
    Header("Location: ../../index.php");
    die();
}
include_once("common.php");
if (!milpacs_is_admin()) {
   Header("Location: /milpacs.php");
}

$drid = intval($drid);
// Load or save?
if ($op != "saveDrillReport") {
   // Load previously saved drill report from database
   if  ($drid > 0) {
      $sql = "SELECT drill_dt, drill_points, drill_news, drill_promotions, drill_assign, drill_tactic, drill_leader FROM " . $prefix . "_milpacs_drills WHERE drill_id = $drid";
      $row = $db->sql_fetchrow($db->sql_query($sql));
      $drill_dt = $row["drill_dt"];
      $drill_points = $row["drill_points"];
      $drill_news = $row["drill_news"];
      $drill_promotions = $row["drill_promotions"];
      $drill_assign = $row["drill_assign"];
      $drill_tactic = $row["drill_tactic"];
      $drill_leader = $row["drill_leader"];
      // Load drill status from table for edit
      $drillstatus = array();
      $sql = "SELECT uniqueid, status FROM " . $prefix . "_milpacs_drill_lkup WHERE drill_id = $drid";
      $result = $db->sql_query($sql);
      while ( $row = $db->sql_fetchrow($result) ) {
         $uniqueid = $row["uniqueid"];
         $drillsts = $row["status"];
         $drillstatus[$uniqueid] = $drillsts;
      }
   // Set defaults for adding new drill report
   } else {
   }
} else {
// Validate
      $error = "";
// Passed validation, save
   if ($error == "") {
      if ($drid > 0) {
         $sql = "UPDATE " . $prefix . "_milpacs_drills set
            drill_dt = '$drill_dt',
            drill_points = $drill_points,
            drill_news = '$drill_news',
            drill_promotions = '$drill_promotions',
            drill_assign = '$drill_assign',
            drill_tactic = '$drill_tactic',
            drill_leader = '$drill_leader'
            WHERE drill_id =$drid";
      } else {
         list($newest_drid) = $db->sql_fetchrow($db->sql_query("SELECT max(drill_id) AS newest_drid FROM ".$user_prefix."_milpacs_drills"));
         if ($newest_drid == "-1") { $drid = 1; } else { $drid = $newest_drid+1; }

         $sql = "INSERT INTO " . $prefix . "_milpacs_drills (
            drill_id,
            drill_dt,
            drill_points,
            drill_news,
            drill_promotions,
            drill_assign,
            drill_tactic,
            drill_leader
            ) VALUES (
            $drid,
            '$drill_dt',
            '$drill_points',
            '$drill_news',
            '$drill_promotions',
            '$drill_assign',
            '$drill_tactic',
            '$drill_leader'
            )";
      }
//      echo "$sql";
      $result = $db->sql_query($sql);
      $sql = "DELETE FROM " . $prefix . "_milpacs_drill_lkup where drill_id = $drid";
      $result = $db->sql_query($sql);
      foreach( $drillstatus as $uniqueid=>$drillsts){
         $uniqueid = intval($uniqueid);
         $drillsts = substr($drillsts,0,10);
         $sql = "INSERT INTO " . $prefix . "_milpacs_drill_lkup (drill_id, uniqueid, status) VALUES ($drid, $uniqueid, '$drillsts')";
         $result = $db->sql_query($sql);
      }
      echo "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=modules.php?name=$module_name&op=drillreport&drid=$drid\">";
      exit();
   }
}
// Load members
$members = array();
$sql = "SELECT mm.uniqueid , mr.rank_abbr, mm.u_name, mm.promotion_dt, mm.position, mm.status FROM " . $prefix . "_milpacs_members mm JOIN " . $prefix . "_milpacs_ranks mr WHERE mm.unit_id != '' AND mm.rank_id = mr.rank_id AND mm.status IN ('Active','LOA') ORDER BY mr.rank_id, mm.promotion_dt asc";
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
   $uniqueid = $row["uniqueid"];
   $rank = $row["rank_abbr"];
   $u_name = $row["u_name"];
   $position = $row["position"];
   $status = $row["status"];
   $members[] = array("uniqueid" => $uniqueid, "u_name" => $u_name, "rank" => $rank, "position" => $position, "status" => $status);
}

?>
</div><div id="dropmsg6" class="dropcontent">
<br>
<?php
OpenTable();
if ($error != "")   echo "<center>$error</center>";
?>
<form name="drillreport" action="milpacs.php?aop=drillreport" method="POST">
<div align="center">
<label><H2>3rd ID Drill Report</H2></label>
<HR>
</div>
<br>
<p>
<strong>Drill Date: </strong>
<INPUT TYPE="text" NAME="drill_dt" size="20" value="<?php echo $drill_dt ?>">
<a href="javascript:showCal('DrillDate');"><img src="images/javascript/calendar.jpg" title='Select Date' alt='Select Date'></a>
&nbsp;&nbsp;<strong>Drill Leader: </strong>
<input type="text" size="30" maxlength="30" name="drill_leader" value="<?php echo $drill_leader ?>">
<br>
<br>
<label><strong>Post the Drill News:</strong></label>
<br>
<textarea name="drill_news" cols="130" rows="2"><?php echo $drill_news ?></textarea>
<br>
<br>
<label><strong>Post any 3rd ID promotions:</strong></label>
<br>
<textarea name="drill_promotions" cols="130" rows="2"><?php echo $drill_promotions ?></textarea>
<br>
<br>
<label><strong>Post any 3rd ID Assignments:</strong></label>
<br>
<textarea name="drill_assign" cols="130" rows="2"><?php echo $drill_assign ?></textarea>
<br>
<br>
<label><strong>Post the tactics used at drills:</strong></label>
<br>
<textarea name="drill_tactic" cols="130" rows="2"><?php echo $drill_tactic ?></textarea>
<br>
<br>
<br><p><strong>Take Attendance:</strong>
<table border=0 width='100%' cellpadding='5'><tr>
<table border=0 width='100%' cellpadding='3'><tr><th width='15%'>Drill Status</th><th width='5%'>Rank</th><th width='15%'><b>Name</b></th><th width='8%'>Position</th><th width='5%'>Status</th>
</tr>
</table>
<table border=0 width='100%' cellpadding='5'>
<?php

// Format drill detail HTML
foreach($members as $member){
   $uniqueid = $member["uniqueid"];
   $rank = $member["rank"];
   $u_name = $member["u_name"];
   $position = $member["position"];
   $status = $member["status"];
   $presentchecked = "";
   $absentchecked = "";
   $excusedchecked = "";
   if ($drillstatus[$uniqueid] == "Absent") { $absentchecked = "CHECKED"; }
   else if ($drillstatus[$uniqueid] == "Excused") { $excusedchecked = "CHECKED"; }
   else { $presentchecked = "CHECKED"; }
   ?>
   <tr>
      <td align="center" width="15%">
         <INPUT TYPE="RADIO" NAME="drillstatus[<?php echo $uniqueid ?>]" VALUE="Present" <?php echo $presentchecked ?> > Present</INPUT>
         <INPUT TYPE="RADIO" NAME="drillstatus[<?php echo $uniqueid ?>]" VALUE="Absent" <?php echo $absentchecked ?> > Absent</INPUT>
         <INPUT TYPE="RADIO" NAME="drillstatus[<?php echo $uniqueid ?>]" VALUE="Excused" <?php echo $excusedchecked ?> > Excused</INPUT>
      </td>
      <td align="center" width="5%">
         <b><font color="#000000"><?php echo $rank ?></font></b>
      </td>
      <td align="center" width="15%">
         <b><font color="#000000"><?php echo $u_name ?></font></b>
      </td>
      <td align="center" width="8%">
         <b><font color="#000000"><?php echo $position ?></font></b>
      </td>
      <td align="center" width="5%">
         <b><font color="#000000"><?php echo $status ?></font></b>
      </td>
   </tr>
   <?php
}
?>
</table>
<input type="submit" align="center" name="Submit" value="Save"/>
<input type="hidden" name="op" value="saveDrillReport"/>
<input type="hidden" name="drid" value="<?php echo $drid ?>"/>
</form>
<?php
CloseTable();
?>


What I am trying to do is an adddrillreport.php page and an editdrillreport.php page

Here is my adddrillreport.php page

Code:
<?php
if (stristr($_SERVER['SCRIPT_NAME'], "adddrillreport.php")) {
    Header("Location: ../../index.php");
    die();
}
include_once("common.php");
if (!milpacs_is_admin()) {
   Header("Location: /milpacs.php");
}
$index = 0;
$module_name = basename(dirname(__FILE__ ));
@include_once("header.php");
// Insert Drill Information
if ($op = "adddrillreport") {
   list($newest_drid) = $db->sql_fetchrow($db->sql_query("SELECT max(drill_id) AS newest_drid FROM ".$user_prefix."_milpacs_drills"));
         if ($newest_drid == "-1") { $drid = 1; } else { $drid = $newest_drid+1; }

         $sql = "INSERT INTO " . $prefix . "_milpacs_drills (
            drill_id,
            drill_dt,
            drill_points,
            drill_news,
            drill_promotions,
            drill_assign,
            drill_tactic,
            drill_leader
            ) VALUES (
            $drid,
            '$drill_dt',
            '$drill_points',
            '$drill_news',
            '$drill_promotions',
            '$drill_assign',
            '$drill_tactic',
            '$drill_leader'
            )";
      }

      $result = $db->sql_query($sql);
      $sql = "DELETE FROM " . $prefix . "_milpacs_drill_lkup where drill_id = $drid";
      $result = $db->sql_query($sql);
// Declare array for drill status
      $drillstatus = array();
      foreach( $drillstatus as $uniqueid=>$drillsts){
         $uniqueid = intval($uniqueid);
         $drillsts = substr($drillsts,0,10);
         $sql = "INSERT INTO " . $prefix . "_milpacs_drill_lkup (drill_id, uniqueid, status) VALUES ($drid, $uniqueid, '$drillsts')";
         $result = $db->sql_query($sql);
      }
      //echo "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=modules.php?name=$module_name&file=drillreport&drid=$drid\">";
      //exit();

// Load members
$members = array();
$sql = "SELECT mm.uniqueid , mr.rank_abbr, mm.u_name, mm.promotion_dt, mm.position, mm.status FROM " . $prefix . "_milpacs_members mm JOIN " . $prefix . "_milpacs_ranks mr WHERE mm.unit_id != '' AND mm.rank_id = mr.rank_id AND mm.status IN ('Active','LOA') ORDER BY mr.rank_id, mm.promotion_dt asc";
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
   $uniqueid = $row["uniqueid"];
   $rank = $row["rank_abbr"];
   $u_name = $row["u_name"];
   $position = $row["position"];
   $status = $row["status"];
   $members[] = array("uniqueid" => $uniqueid, "u_name" => $u_name, "rank" => $rank, "position" => $position, "status" => $status);
}
OpenTable();
?>
<form name="adddrillreport" action="modules.php?name=<?php echo $module_name ?>" method="POST">
<div align="center">
<label><H2>Add Drill Report</H2></label>
<HR>
</div>
<br>
<p>
<strong>Drill Date: </strong>
<INPUT TYPE="text" NAME="drill_dt" size="20" value="<?php echo $drill_dt ?>">
<a href="javascript:showCal('addDrillDate');"><img src="images/javascript/calendar.jpg" title='Select Date' alt='Select Date'></a>
&nbsp;&nbsp;<strong>Drill Leader: </strong>
<input type="text" size="30" maxlength="30" name="drill_leader" value="<?php echo $drill_leader ?>">
<br>
<br>
<label><strong>Post the Drill News:</strong></label>
<br>
<textarea name="drill_news" cols="130" rows="2"><?php echo $drill_news ?></textarea>
<br>
<br>
<label><strong>Post any 3rd ID promotions:</strong></label>
<br>
<textarea name="drill_promotions" cols="130" rows="2"><?php echo $drill_promotions ?></textarea>
<br>
<br>
<label><strong>Post any 3rd ID Assignments:</strong></label>
<br>
<textarea name="drill_assign" cols="130" rows="2"><?php echo $drill_assign ?></textarea>
<br>
<br>
<label><strong>Post the tactics used at drills:</strong></label>
<br>
<textarea name="drill_tactic" cols="130" rows="2"><?php echo $drill_tactic ?></textarea>
<br>
<br>
<br><p><strong>Take Attendance:</strong>
<table border=0 width='100%' cellpadding='5'><tr>
<table border=0 width='100%' cellpadding='3'><tr><th width='15%'>Drill Status</th><th width='5%'>Rank</th><th width='15%'><b>Name</b></th><th width='8%'>Position</th><th width='5%'>Status</th>
</tr>
</table>
<table border=0 width='100%' cellpadding='5'>
<?php

// Format drill detail HTML
foreach($members as $member){
   $uniqueid = $member["uniqueid"];
   $rank = $member["rank"];
   $u_name = $member["u_name"];
   $position = $member["position"];
   $status = $member["status"];
   $presentchecked = "";
   $absentchecked = "CHECKED";
   $excusedchecked = "";   
   ?>
   <tr>
      <td align="center" width="15%">
         <INPUT TYPE="RADIO" NAME="drillstatus[<?php echo $uniqueid ?>]" VALUE="Present" <?php echo $presentchecked ?> > Present</INPUT>
         <INPUT TYPE="RADIO" NAME="drillstatus[<?php echo $uniqueid ?>]" VALUE="Absent" <?php echo $absentchecked ?> > Absent</INPUT>
         <INPUT TYPE="RADIO" NAME="drillstatus[<?php echo $uniqueid ?>]" VALUE="Excused" <?php echo $excusedchecked ?> > Excused</INPUT>
      </td>
      <td align="center" width="5%">
         <b><font color="#000000"><?php echo $rank ?></font></b>
      </td>
      <td align="center" width="15%">
         <b><font color="#000000"><?php echo $u_name ?></font></b>
      </td>
      <td align="center" width="8%">
         <b><font color="#000000"><?php echo $position ?></font></b>
      </td>
      <td align="center" width="5%">
         <b><font color="#000000"><?php echo $status ?></font></b>
      </td>
   </tr>
   <?php
}
?>
</table>
<input type="submit" align="center" name="Submit" value="Save"/>
<input type="hidden" name="op" value="saveDrillReport"/>
<input type="hidden" name="drid" value="<?php echo $drid ?>"/>
</form>
<?php
CloseTable();
?>



Doesn't quite work. If I can get one working I'm sure I can get the editdrillreport.php working from there.

Thanks for any help.
View user's profile Send private message Visit poster's website ICQ Number
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Sat Feb 25, 2006 3:56 pm Reply with quote Back to top

Donovan,

I missed this post, originally. Sorry! Did you ever resolve it?
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Donovan
Client


Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Mon Feb 27, 2006 1:40 pm Reply with quote Back to top

Yes...Took some thinking. I think Evaders helped as well.
View user's profile Send private message Visit poster's website ICQ Number
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum