Code: Select all
class Match
{
	// constant for open Match
	const STATUS_OPEN = 0;
	// constant for completed Match
	const STATUS_COMPLETED = 1;
	// constant for cancelled Match
	const STATUS_CANCELLED = 2;
	// constant for match that was result of error
	const STATUS_ERROR = 3;
	// match id
	private $matchID = array();
	// challenger of match
	private $challenger = array();
	// defender of match
	private $defender = array();
	// instance of database
	protected $db;
	/**
	* class constructor
	* @param $db database class instance
	*/
    public function __construct(Database $db)
    {
        // get instance of database
        $this->db = $db;
    }
	/**
	* get the current matches the playerhas pending
	* @username username to check for matches for
	*/
	public function getMatches($username)
	{
		// prepare the sql statement to change the password
        $statement = $this->db->prepare("SELECT challenger, defender FROM " . TABLE_MATCHINDEXES . " WHERE challenger = ? or defender = ? and status = ? LIMIT 5");
        // bing the variables
        $statement->bind_param('ssi', $username, $username, $self::STATUS_OPEN);
        // if the statement executed successfully
        if ($statement->execute())
        {
        	// get the number of results
			$statement->bind_result($challenger, $defender);
			// fetch the results
			$statement->fetch();
			// if a result exists
			if($challenger || $defender)
			{
				// set the challenger
				$this->challenger[] = $challenger;
				// set the defender
				$this->defender[] = $defender;
				// return true
				return true;
			}
            // so matches were found so return true
            return true;
        }
        // the query failed so return false
        return false;
	}
}
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Aleeious - Pending Challanges</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="templates/css/style.css" media="screen" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta name="mobile-web-app-capable" content="yes" />
</head>
 <body>
<h1>Pending Challenges</h1>
<table>
<tr>
<td>Challenger</td><td>Defender</td><td>Accept</td><td>Decline</td>
</tr>
{foreach $challengers as $challenger}
{foreach $defenders as $defender}
<tr>
<td>{$challenger}</td><td>{$defender}</td><td><a href="{$acceptlink}" title="Click here to accept this match">[accept]</a></td><td><a href="{$declinelink}" title="Click here to decline this match">[decline]</a></td>
</tr>
{/foreach}
{/foreach}
</table>
<p><a href="main.php" title="Click here to return to the main menu" accesskey="1">back</a></p>
</body>
</html>
Sincerely,
Aleeious
