Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/course2.php
<?
include("dbasecon.inc.php");
include("session.inc.php");
include ("header.php");
include ("coursefunctions.inc.php");

if ($HTTP_POST_VARS['SubmitCourse']) {


//first check see if course already exist and the login name is right

$coursechecksql="select * from courses where 
								 courseid='$courseid'
								 and owner='$login_id'";
				$coursecheckquery=mysql_query($coursechecksql);
				$coursecheckrow=mysql_fetch_array($coursecheckquery);
				$coursecheckexist=mysql_numrows($coursecheckquery);
				
				
if ($coursecheckexist) {				
$coursenumid=$coursecheckrow['ID'];
$hole=0;
$holepar=0;
$front9=0;
$back9=0;
$coursepar=0;
$courselength=0;
$front9length=0;
$back9length=0;

do {
$hole++;
$parhole=parhole.$hole;
$lengthhole=lengthhole.$hole;
//1. count the fron, back 9 and total par
$holepar=${$parhole};

//2.count the front, back 9 ,total courselength
$holelength=${$lengthhole};

if ($hole<=9) {
$front9=$front9+$holepar;
$front9length=$front9length+$holelength;
}else {
$back9=$back9+$holepar;
$back9length=$back9length+$holelength;

}


 
} while ($hole<18);

$coursepar=$back9+$front9;
$courselength=$back9length+$front9length;

//echo $front9length;

$scoreupdatesql="UPDATE courses SET coursename= '$reqcoursename', courseaddress= '$courseaddress', coursestate= '$coursestate', 
courserating= '$reqcourserating', sloperating= '$reqsloperating', coursepar= '$coursepar', courselength= '$courselength',
front9length= '$front9length', front9= '$front9', back9= '$back9', back9length= '$back9length', coursephone= '$coursephone', 
coursefax= '$coursefax', courseweb= '$courseweb', coursenotes= '$coursenotes', 
parhole1= '$parhole1', indexhole1='$indexhole1', lengthhole1= '$lengthhole1',
parhole2= '$parhole2', indexhole2='$indexhole2', lengthhole2= '$lengthhole2',
parhole3= '$parhole3', indexhole3='$indexhole3', lengthhole3= '$lengthhole3',
parhole4= '$parhole4', indexhole4='$indexhole4', lengthhole4= '$lengthhole4',
parhole5= '$parhole5', indexhole5='$indexhole5', lengthhole5= '$lengthhole5',
parhole6= '$parhole6', indexhole6='$indexhole6', lengthhole6= '$lengthhole6',
parhole7= '$parhole7', indexhole7='$indexhole7', lengthhole7= '$lengthhole7',
parhole8= '$parhole8', indexhole8='$indexhole8', lengthhole8= '$lengthhole8',
parhole9= '$parhole9', indexhole9='$indexhole9', lengthhole9= '$lengthhole9',
parhole10= '$parhole10', indexhole10='$indexhole10', lengthhole10= '$lengthhole10',
parhole11= '$parhole11', indexhole11='$indexhole11', lengthhole11= '$lengthhole11',
parhole12= '$parhole12', indexhole12='$indexhole12', lengthhole12= '$lengthhole12',
parhole13= '$parhole13', indexhole13='$indexhole13', lengthhole13= '$lengthhole13',
parhole14= '$parhole14', indexhole14='$indexhole14', lengthhole14= '$lengthhole14',
parhole15= '$parhole15', indexhole15='$indexhole15', lengthhole15= '$lengthhole15',
parhole16= '$parhole16', indexhole16='$indexhole16', lengthhole16= '$lengthhole16',
parhole17= '$parhole17', indexhole17='$indexhole17', lengthhole17= '$lengthhole17',
parhole18= '$parhole18', indexhole18='$indexhole18', lengthhole18= '$lengthhole18'
WHERE ID='$coursenumid'";

//echo $scoreupdatesql;
$scoreupdateresult=mysql_query($scoreupdatesql);

$error="$reqcoursename has been updated.";


} else {

$error="Error in updating. Please contact administrator.";

} //endif courseexist




} //endif submit course




//get list of courses

$coursesql="select * from courses   
					where owner = '$login_id'
					and courseid='$courseid'";

				$coursequery=mysql_query($coursesql);
				$courserow=mysql_fetch_array($coursequery);
				$courseexist=mysql_numrows($coursequery);
				extract($courserow);			

				if (!$courseexist) {
				echo "Invalid Input. No priveleges.Exiting";
				exit();
				
				}
				
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<? showheader("Course Manager"); ?>

<? echo "<p class='error'>".$error."<p>"; ?>



<?

if (($action=="change") || ($coursecheckexist)) {
?>
<table border=0>
<tr>
<td>
<FORM action="<?=$PHP_SELF?>" method=post onSubmit="return checkrequired(this)">
            
            <TABLE border=0 cellPadding=1 cellSpacing=1>
              <TBODY>
              <TR>
                <TD>Course ID</TD>
                <TD><? echo $courseid;?></TD></TR>
              <TR>
                <TD>Course Name</TD>
                <TD><INPUT name=reqcoursename value="<? echo $coursename; ?>"></TD></TR>
              <TR>
                <TD>Website</TD>
                <TD><INPUT name=courseweb  value="<? echo $courseweb; ?>"></TD></TR>
              <TR>
                <TD>Address</TD>
                <TD><INPUT name=courseaddress value="<? echo $courseaddress; ?>"></TD></TR>
              <TR>
                <TD>State</TD>
                <TD><INPUT name=coursestate value="<? echo $coursestate; ?>"></TD></TR>
              <TR>
                <TD>Telephone</TD>
                <TD><INPUT name=coursephone maxlength=15 value="<? echo $coursephone; ?>"></TD></TR>
              <TR>
                <TD>Fax</TD>
                <TD><INPUT name=coursefax maxlength=15 value="<? echo $coursefax; ?>"></TD></TR>
                  <TR>


       </TABLE>

</td>
<td>
            <TABLE border=0 cellPadding=1 cellSpacing=1>

<TD>Notes</TD>
                <TD><TEXTAREA name=coursenotes rows="10" cols="50"><? echo "$coursenotes"; ?></TEXTAREA></TD></TR>
              <TR>
                <TD>&nbsp;</TD>
                <TD></TD></TR></TBODY>

</table>

</td>
</tr>								
</table>



<form name="newHoleForm" method="post" action="?p=6.1" onSubmit="return verify(this);">
	<table border="1" cellspacing="1" cellpadding="1">
		<tr> 
			<td colspan="3">Hole</td>
			<td align="center">1</td>
			<td align="center">2</td>
			<td align="center">3</td>
			<td align="center">4</td>
			<td align="center">5</td>
			<td align="center">6</td>
			<td align="center">7</td>
			<td align="center">8</td>
			<td align="center">9</td>
			<td align="center">10</td>
			<td align="center">11</td>
			<td align="center">12</td>
			<td align="center">13</td>
			<td align="center">14</td>
			<td align="center">15</td>
			<td align="center">16</td>
			<td align="center">17</td>
			<td align="center">18</td>
		</tr>
		<tr> 
			<td colspan="3">Par</td>

			<?
			$holecount=0;
			do {
			$holecount++;		
			$parholecount=parhole.$holecount;
			echo "<td align='center'><select name=\"$parholecount\">";
	    if (!${$parholecount}) { ${$parholecount}=4;}			
		$listpars = listpars("5", "${$parholecount}");
		echo "$listpars";
		echo "</select></td>";			
			} while ($holecount<18);
			
			?>
				</tr>
		<tr> 
			<td>Slope Rt.</td>
			<td>Course Rt.</td>
			<td>&nbsp;</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
			<td><?echo $measure;?> | Index</td>
		</tr>
		<tr> 
			<td><input type="text" size="3" name="reqsloperating" value="<? echo $sloperating; ?>"></td>
			<td><input type="text" size="3" name="reqcourserating" value="<? echo $courserating; ?>"></td>
			<td>&nbsp;</td>

			
						<?
			$holecount=0;
			do {
			$holecount++;		
			$parholecount=parhole.$holecount;
			$lengthholecount=lengthhole.$holecount;
			$indexholecount=indexhole.$holecount;
			echo "<td><input type='text' maxlength='3' size='3' name=\"$lengthholecount\" value='${$lengthholecount}'>";
			echo "<br><select name=\"$indexholecount\">";
			
				    if (!${$indexholecount}) { ${$indexholecount}=1;}			
		$listindex = listindex("18", "${$indexholecount}");
		echo "$listindex";
		echo "</select></td>";			

			} while ($holecount<18);
			
			?>

			
		</tr>
	</table>
<p>
<center>
<input type="Hidden" name="courseid" value="<?echo $courseid;?>" >
<INPUT name="SubmitCourse" type="submit" value="Submit Course">
</center>
</form>

<?
} //endif action=change

?>

<? showfooter(); ?>
Return current item: GolfstatsPHP