if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST["mem_num"]) && is_numeric($_POST["mem_num"])) { $mem_num = $_POST["mem_num"]; } else { echo form_subtitle('Must include fighter membership number to print fighter authorization card'); exit_with_footer(); } if (isset($_POST["id_combat"]) && is_numeric($_POST["id_combat"])) { $id_combat = $_POST["id_combat"]; } } else { echo form_subtitle("Page accessed in error."); exit_with_footer(); } if (DEBUG) { echo form_subsubtitle("Now using values mem_num={$mem_num} and id_combat={$id_combat}"); } // Open database $cxn = open_db_browse(); // Confirm that there is a fighter authorization card on file for this person and combat type $query = "SELECT Persons.id_person, id_person_combat_card, Combat.id_combat, name_combat " . "FROM Persons, Persons_CombatCards, Combat " . "WHERE Persons.id_person=Persons_CombatCards.id_person " . "AND membership_person={$mem_num} " . "AND Combat.id_combat = Persons_CombatCards.id_combat " . "AND Combat.id_combat={$id_combat};"; if (DEBUG) { echo "Find person query is: {$query}<p>"; } $result = mysqli_query($cxn, $query) or die("Couldn't find authorization card"); // Now check: if we returned a result we have id_person. If not, exit out with card not found. // Note: we will return either 1 row, or 0. $num_rows = mysqli_num_rows($result); if ($num_rows < 1) { echo "Couldn't find authorization card given Combat type and Membership Number.<p>"; echo '<a id="back" href="combat.php">Back to the Combat Page!</a>';
$query = "SELECT name_combat, name_marshal, Persons_CombatCards.expire_marshal \n FROM Persons_Marshals, Marshals, Combat, Persons_CombatCards\n WHERE Persons_CombatCards.id_person={$id_person} \n AND Persons_Marshals.id_person={$id_person}\n AND curdate()<= Persons_CombatCards.expire_marshal\n AND Marshals.id_combat=Combat.id_combat\n AND Persons_Marshals.id_marshal=Marshals.id_marshal\n AND Persons_CombatCards.id_combat = Combat.id_combat\n ORDER by name_combat, Marshals.id_marshal"; //$query = "SELECT name_combat, name_marshal, expire_marshal // FROM Persons_Marshals, Marshals, Combat // WHERE Persons_Marshals.id_marshal = Marshals.id_marshal // AND Marshals.id_combat = Combat.id_combat // AND id_person = $id_person // AND curdate()<= expire_marshal // ORDER by name_combat, Marshals.id_marshal"; if (DEBUG) { echo "Marshal Warrants query is:{$query}<p>"; } $result = mysqli_query($cxn, $query) or die("Couldn't execute marshaling query"); $matches = $result->num_rows; if ($matches > 0) { $ocombat = ""; echo form_subsubtitle("Marshal's Warrants on file:"); while ($row = mysqli_fetch_assoc($result)) { extract($row); if ($ocombat != $name_combat) { echo "<br><b>{$name_combat} (expires {$expire_marshal})</b>: {$name_marshal}"; } else { echo ",  {$name_marshal}"; } $ocombat = $name_combat; } echo "<br>"; } echo "<br>"; //} /* query: select a person's awards in the database */ $query = "SELECT Awards.id_award, name_award, date_award,name_kingdom, name_event, Events.id_event\n FROM Persons, Persons_Awards, Awards, Kingdoms, Events\n WHERE Persons.id_person = Persons_Awards.id_person\n AND Persons_Awards.id_award = Awards.id_award\n AND Awards.id_kingdom = Kingdoms.id_kingdom\n AND Persons_Awards.id_event = Events.id_event \n AND Persons.id_person = {$id_person} order by date_award";