PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Bogdan Zarchievici   ELO Calculator   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: ELO Calculator
Calculates the relative skill levels of players
Author: By
Last change: 2005-06-10: Removed the class from the example.
Date: 18 years ago
Size: 1,713 bytes
 

Contents

Class file image Download
<?

require('elo-calculator.php');

if (!empty(
$_POST['S1']) OR !empty($_POST['S2']) OR !empty($_POST['R1']) OR !empty($_POST['R2']))
{
$elo_calculator=&new elo_calculator;
 
$results=$elo_calculator->rating($_POST['S1'],$_POST['S2'],$_POST['R1'],$_POST['R2']);
 
$R=$results; /* variable alias. not required but easier for me to write the example */ }

echo
'<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
echo
'<table>';
echo
'<tr><td>&nbsp;</td>';
echo
' <td>Player 1</td>';
echo
' <td>Player 2</td></tr>';
echo
'<tr><td>Points:</td>';
echo
' <td><input type="text" size="5"name="R1" value="'; if (!empty($R['R1'])) { echo $R['R1']; } echo '"/></td>';
echo
' <td><input type="text" name="R2" size="5" value="'; if (!empty($R['R2'])) { echo $R['R2']; } echo '"/></td></tr>';
echo
'<tr><td>Match Results:</td>';
echo
' <td><input type="text" name="S1" size="5" value="'; if (!empty($R['S1'])) { echo $R['S1']; } echo '"/></td>';
echo
' <td><input type="text" name="S2" size="5" value="'; if (!empty($R['S2'])) { echo $R['S2']; } echo '"/></td></tr>';
echo
'<tr><td>Points gained/lost:</td>';
echo
' <td>'; if (!empty($R['P1'])) { echo $R['P1']; } echo '</td>';
echo
' <td>'; if (!empty($R['P2'])) { echo $R['P2']; } echo '</td></tr>';
echo
'<tr><td>Final results:</td>';
echo
' <td><input type="text" size="5" name="" value="'; if (!empty($R['R3'])) { echo $R['R3']; } echo '"/></td>';
echo
' <td><input type="text" size="5" name="" value="'; if (!empty($R['R4'])) { echo $R['R4']; } echo '"/></td>';
echo
'<tr><td>&nbsp;</td>';
echo
' <td colspan="2">';
echo
' <input type="submit" value="Calculate"/></td></tr>';
echo
'</table>';

?>