Advertisement

04.05.2008 at 06:30AM PDT, ID: 23298279
[x]
Attachment Details

Set Match Outcome?

Asked by m0tSiE in PHP and Databases, PHP Scripting Language

Tags:

Hi,

I've been racking my brains trying to work this out but I can't seem to do it.

At the minute I have a table set up where members can challenge each other to play an online game, the whole challenge part is done and I can show the accepted matches, etc.

However the last part I'm setting up is the ability to enter the outcome of the match and have the other person confirm it, if it's confirmed then I want to set the "status" field to "closed".

At the moment I am using the attached code, which displays the matches where the date & time have passed and are now eiligible to enter the outcome for.

Can anyone show see how I can set this up so that if the Challenger / Oppoenent hasn't entered an outcome they get a drop down box to enter the outcome of the match, containing the outcomes below:

$challenger
$opponent
Draw

So whichever is selected, it then updates the "chall_outcome" field if it is the challenger submitting the outcome, or the "opp_outcome" field if it is the opponent selecting the outcome.

You can check to see if the challenger or the opponent is the person entering the score by checking the "opponent" or "challenger" fields against $gamertag, as $gamertag is the name of the person who is logged in.

Finally I need it so that if the outcome entered in the "opp_outcome" and "chall_outcome" fields are the same, then the "oucome" field is set to that value.

Sorry if I haven't made this too clear, it seemed really complicated to work out.
If you can think of any easier ways I can accomplish this then please let me know,

Thanks,
Paul.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
<?php 
// Connects to your Database 
mysql_connect("", "", "") or die(mysql_error()); 
mysql_select_db("") or die(mysql_error()); 
 
echo "<table border='0' width='100%' cellspacing='0'>
	<tr>
		<td class='toplinks' style='border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-style: solid; border-bottom-width: 1px; padding-bottom:4px' bordercolor='#DCE0EF' align='center'>
		<b><font size='3' color='#407CBF'>Matches Awaiting Results</font></b></td>
	</tr>
</table>
<p>
<center>
<table border='0' cellspacing='0' cellpadding='0' class='test'>
 
	<tr>
		<td class='results-header-left' width='20'>ID</td>
		<td class='results-header' width='170'>Challenger</td>
		<td class='results-header' width='170'>Opponent</td>
		<td class='results-header' width='120'>Match Type</td>
		<td class='results-header' width='120'>League</td>
		<td class='results-header' width='80'>Date</td>
		<td class='results-header' width='80'>Time</td>
		<td class='results-header' width='120'>Outcome</td>
	</tr>";
 
$enterresults = "SELECT * 
    FROM challenges 
   WHERE ( challenger LIKE '$gamertag' OR opponent LIKE '$gamertag' ) 
     AND status= 'open' 
     AND accepted= 'Yes' 
	 AND date < CURDATE() OR (date = CURDATE() AND time < CURTIME())
     ORDER BY id " ;
 
 
$enterresults2 = mysql_query($enterresults); 
 
$arr_data = array();
 
echo mysql_error(); 
 
while ($row = mysql_fetch_assoc($enterresults2))
{
 
$id=$row["id"];
$challenger=$row["challenger"];
$opponent=$row["opponent"];
$opp_score=$row["opp_score"];
 
        print "
        <tr>
		<td class=results-show-left>$id</td>
		<td class=results-show><a href='member.php?q=$challenger'>$challenger</a></td>
		<td class=results-show><a href='member.php?q=$opponent'>$opponent</a></td>
		<td class=results-show>{$row["matchtype"]}</td>
		<td class=results-show>{$row["league"]}</td>
		<td class=results-show>{$row["date"]}</td>
		<td class=results-show>{$row["time"]}</td>
		<td class=results-show>ENTER OUTCOME WILL GO HERE</td>
</tr>";
 }
 
      print "
 
</table>
</center>
</p>
 
<table border='0' width='100%' cellspacing='0'>
	<tr>
		<td class='toplinks' style='border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-style: solid; border-bottom-width: 1px; padding-bottom:4px' bordercolor='#DCE0EF' align='center'>&nbsp;</td>
	</tr>
</table>
 
</body>
 
</html>
	 "; 
} 
 
?>
[+][-]04.05.2008 at 07:44AM PDT, ID: 21288309

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.05.2008 at 08:25AM PDT, ID: 21288439

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.05.2008 at 08:34AM PDT, ID: 21288467

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.05.2008 at 08:40AM PDT, ID: 21288487

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.05.2008 at 09:00AM PDT, ID: 21288556

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.05.2008 at 12:52PM PDT, ID: 21289375

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP and Databases, PHP Scripting Language
Tags: PHP, mySQL
Sign Up Now!
Solution Provided By: rowejd
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628