PHP Classes
Icontem

File: agolfhandicap.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of George Clarke  >  A Golf Handicap  >  agolfhandicap.php  
File: agolfhandicap.php
Role: Example script
Content type: text/plain
Description: Example script for AGolfHandicap class
Class: A Golf Handicap
Record played golf games in a MySQL database
 

Contents

Class file image Download
<?php
// This is an example script using the agolfhandicap class to record games played
// and calculate your golf handicap index.
// It is a multi user database and can keep track of games for different players.
// First enter your name or user name then the game information.
// This script really should be used with a user/password login system for security.
//
// Version 1.1.0: Added Edit and Delete for a record in the database. 
//
// ############ You must edit the username, password and database name further down.

include "class.agolfhandicap.php";
$gh=new agolfhandicap();

// ######### Edit the next line to put your MySQL username, password, and database name. ########
$gh->setupdb('username','password','databasename');

// Get the user name if submitted.
if($_POST['user']){
 
$user=$_POST['user'];
 
$gh->setuser($user);
}
if(
$_POST['delete']){          //delete the record
  
$id=$_POST['id'];
  
$gh->deleteGame($id);
}
if(
$_POST['edit']){           //edit the record
  
$id=$_POST['id'];
}
// If no user yet, ask for it.
if(!isset($_POST['user'])){
 print 
"<form name='usr' action='$PHP_SELF' method='POST'>";
 print 
"Enter your user name:<input type='text' name='user' size='20'>";
 print 
"<input type='hidden' name='hid' value='true'>";
 print 
"<input type='submit' value='Submit' name='submits'>";
 print 
"</form>";
}else{
// We have a username, so get new game data and display handicap and all games.
print "<h2>Golf Game Database and Handicap Calculator for $user</h2>\n";
$newgame=$gh->getnewgame($id);
$id=($_POST['edit']=="")? "":$id;
$gh->showform($id);
$hc=$gh->gethcap();
print (
$hc==0)?"<h3>You need at least 5 games for a handicap index.</h3>":"<h3>Handicap for $user is $hc</h3><br>";
// If you just want the data without displaying it, use next line.
//$al=$gh->getAll();
$gh->showall();
}
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products