Help needed with this project
Posted: Thu Dec 11, 2003 3:01 am
hi guys i'am pretty new to php and self taught so be gentle with me
ok i'am trying to make this grading sheet which seems to work ok till i hit the submit button which takes me to a page that shows the modifications that should have been made the problem i cant seem to sort is this it will display the guys name fine at the top but it will put the grade in for all the course's and dosnt update the db its driving me nuts trying to find the cause of this any way any help much appreiacted i'am sure its something silly i've overlooked heres the code
and the 2nd page displays here
ok i'am trying to make this grading sheet which seems to work ok till i hit the submit button which takes me to a page that shows the modifications that should have been made the problem i cant seem to sort is this it will display the guys name fine at the top but it will put the grade in for all the course's and dosnt update the db its driving me nuts trying to find the cause of this any way any help much appreiacted i'am sure its something silly i've overlooked heres the code
Code: Select all
<html>
<head>
<title>TTS Phase LOG </title>
</head>
<body>
<?php
//create connection
include("cfg.php");
$sql = "select callsign, iff101, iff201, iff301, iff302, iff401, iff402, iff501, iff502, fmn101, fmn201, fmn202, fmn203, fmn204, nav101, nav201, fpe
from training
order by callsign";
$sql_result = mysql_query($sql,$connection) or die ("cant connect");
// Display the training log here
echo "<h3><p align=center> TTS Phase LOG </p></h3>";
echo "<p align=center><table border=3 cellspacing=1 cellpadding=0 bordercolor=\#204165\>";
echo"<tr><th>CallSign</th><th>IFF 1-01</th><th>IFF 2-01</th><th>IFF 3-01</th><th>IFF 3-02</th><th>IFF 4-01</th><th>IFF 4-02</th><th>IFF 5-01</th><th>IFF 5-02</th><th>FMN 1-01</th><th>FMN 2-01</th><th>FMN 2-02</th><th>FMN 2-03</th><th>FMN 2-04</th><th>NAV 1-01</th><th>NAV 2-01</th><th>FPE-RDY</th></tr></p>";
//format by row
while ($row = mysql_fetch_array($sql_result)){
$callsign = $row ї"callsign"];
$iff101 = $row ї"iff101"];
$iff201 = $row ї"iff201"];
$iff301 = $row ї"iff301"];
$iff302 = $row ї"iff302"];
$iff401 = $row ї"iff401"];
$iff402 = $row ї"iff402"];
$iff501 = $row ї"iff501"];
$iff502 = $row ї"iff502"];
$fmn101 = $row ї"fmn101"];
$fmn201 = $row ї"fmn201"];
$fmn202 = $row ї"fmn202"];
$fmn203 = $row ї"fmn203"];
$fmn204 = $row ї"fmn204"];
$nav101 = $row ї"nav101"];
$nav201 = $row ї"nav201"];
$fpe = $row ї"fpe"];
echo "<tr><td><b>$callsign</b></td><td><b>$iff101</b></td><td><b>$iff201</b></td><td><b>$iff301</b></td><td><b>$iff302</b></td><td><b>$iff401</b></td><td><b>$iff402</b></td><td><b>$iff501</b></td><td><b>$iff502</b></td><td><b>$fmn101</b></td><td><b>$fmn201</b></td><td><b>$fmn202</b></td><td><b>$fmn203</b></td><td><b>$fmn204</b></td><td><b>$nav101</b></td><td><b>$nav201</b></td><td><b>$fpe</b></td></tr>";
}
echo "</table></p>";
echo "<p align=center><b>Q+ = Passed with distinction, Q = passed, NG = No Grade, U = Major deviations from recommended procedures</b></P>";
echo "</table>";
//end the log
//now lets grade the guys with the stuff below
//Select a guy to Grade here
echo "<table BORDER="0" ALIGN="left" cellspacing="4" cellpadding="4">\n";
echo " <FORM method="POST" action="grade3.php">\n";
echo " <tr>\n";
echo " <td align=center COLSPAN="3">\n";
echo " <H3>Grade a Recruit</H3></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align=right VALIGN="MIDDLE">\n";
echo " <td VALIGN="MIDDLE">\n";
echo " <select name="sel_record">\n";
echo " <option value=""> -- Select a Recruit-- </option>\n";
$sql = "SELECT callsign
from training ";
$sql_result = mysql_query($sql)
or die("Couldn't execute query.");
while ($row = mysql_fetch_array($sql_result)){
$callsign = $row ї"callsign"];
echo " <option value="$callsign">$callsign</option>";
}
echo " </select>\n";
//Select the Training the guys done
echo " <td VALIGN="MIDDLE">\n";
echo " <select name="sel_phase">\n";
echo " <option value=""> -- Phase to be graded -- </option>\n";
$sql = "select title
from tts_training_type ";
$sql_result = mysql_query($sql)
or die("Couldn't execute query.");
while ($row = mysql_fetch_array($sql_result)){
$title = $rowї"title"];
echo " <option value="$title">$title</option>";
}
echo " </select>\n";
//Give the guy a grade
echo " <td VALIGN="MIDDLE">\n";
echo " <select name="sel_grade">\n";
echo " <option value=""> -- Grade -- </option>\n";
$sql = "SELECT title
from tts_grade ";
$sql_result = mysql_query($sql)
or die("Couldn't execute query.");
while ($row = mysql_fetch_array($sql_result)){
$title = $row ї"title"];
echo " <option value="$title">$title</option>";
}
echo " </select>\n";
echo " </td>\n";
echo " </td>\n";
echo " <td align=center colspan=1 VALIGN="MIDDLE">\n";
echo " <INPUT type="submit" value="Grade Recruit"></TD>\n";
echo " <tr>\n";
echo " </form>\n";
//lets free the mysql db resources
mysql_free_result($sql_result);
mysql_close($connection);
echo "</table>\n";
?>Code: Select all
<?
if ((!$sel_record || (!$sel_phase) || (!$sel_grade))) {
header("Location: http://localhost/tts/index.php");
exit;
}
?>
<html>
<head>
<title>TTS Grade3 </title>
</head>
<body>
<?
$sql = "update training
set iff101 = "$iff101", iff201 = "$iff201",
iff301 = "$iff301", iff302 = "$iff302", iff401 = "$iff401", iff402 = "$iff402", iff501 = "$iff501", iff502 = "$iff502", fmn101 = "$fmn101", fmn201 = "$fmn201", fmn202 = "$fmn202", fmn203 = "$fmn203", fmn204 = "$fmn204", nav101 = "$nav101", nav201 = "$nav201", fpe = "$fpe"
WHERE callsign = "$callsign"";
include("cfg.php");
$sql_result = mysql_query($sql)
or die("Couldn't execute query.");
if (!$sql_result) {
echo "<P>Couldn't modify record!";
} else {
echo "
<h1><p align=Center>You have made the following modifications:</p></h1>
<table cellspacing=5 cellpadding=5 align=center>
<tr>
<td valign=center><strong>callsign:</strong></td>
<td valign=center>$sel_record</td>
</tr>
<tr>
<td valign=middle><strong>IFF 1-01:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>IFF 2-01:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>IFF 3-01:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>IFF 3-02:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>IFF 4-01:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>IFF 4-02:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>IFF 5-01:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>IFF 5-02:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>FMN 1-01:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>FMN 2-01:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>FMN 2-02:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>FMN 2-03:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>FMN 2-04:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>NAV 1-01:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>NAV 2-01:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
<tr>
<td valign=middle><strong>FPE:</strong></td>
<td valign=middle>$sel_grade</td>
</tr>
</table>
</p>
<p align=center><a href="index.php">Return to the IFF LOG</a></p>
<p align=center><a href=ipadmin.php> Instructor Pilots Admin Area </p></a>
";
}
?>
</body>
</html>