Hey.
jeg skal lave en table ved navn "tplls_scores" jeg har prøvet men den table er ikke rigtig..
Scriptet er rigtigt.. jeg har bare brug for den mysql table der høre til..
<?php
/*
***************************************************************************
tplLeagueStats modified and expanded by LaX
- Scores page
***************************************************************************
*/
session_start();
$sessioid = $_REQUEST['sessioid'];
$sessio = $_SESSION['sessio'];
//Check the session id
if(!isset($sessioid) || $sessioid != "$sessio")
{
print("Authorization failed.<br>
<a href=\\"index.php\\">Restart, please</a>");
}
else
{
//Connect to the database and select used database
include('user.php');
$connection = mysql_connect("$host","$user","$password")
or die(mysql_error());
mysql_select_db("$txt_db_name",$connection)
or die(mysql_error());
$seasonid = $_SESSION['season_id'];
$seasonname = $_SESSION['season_name'];
$PHP_SELF = $_SERVER['PHP_SELF'];
$HTTP_REFERER = $_SERVER['HTTP_REFERER'];
$action = $_REQUEST['action'];
$rule_submit = $_POST['rule_submit'];
//
//Add
//
if($rule_submit)
{
$home_goals = trim($_POST['homer']);
$away_goals = trim($_POST['awayr']);
$rap1 = trim($_POST['rap1']);
$rap2 = trim($_POST['rap2']);
$matchid = $_POST['matchid'];
if($homer != '' && $awayr != '' && $matchid != '')
{
$get_match = mysql_query("SELECT * FROM tplls_leaguematches WHERE LeagueMatchID = '$matchid' LIMIT 1",$connection)
or die(mysql_error());
$data = mysql_fetch_array($get_match);
$home = $data[LeagueMatchHomeID];
$away = $data[LeagueMatchAwayID];
//
//Set default
//
$home_winner = -1;
$home_loser = -1;
$home_tie = -1;
$away_winner = -1;
$away_loser = -1;
$away_tie = -1;
//
//Home wins
//
if($home_goals > $away_goals)
{
$home_winner = $home;
$away_loser = $away;
}
//
//Away wins
//
elseif($home_goals < $away_goals)
{
$away_winner = $away;
$home_loser = $home;
}
//
//Draw
//
elseif($home_goals == $away_goals)
{
$home_tie = $home;
$away_tie = $away;
}
mysql_query("
UPDATE tplls_leaguematches SET
LeagueMatchHomeWinnerID = '$home_winner',
LeagueMatchHomeLoserID = '$home_loser',
LeagueMatchAwayWinnerID = '$away_winner',
LeagueMatchAwayLoserID = '$away_loser',
LeagueMatchHomeTieID = '$home_tie',
LeagueMatchAwayTieID = '$away_tie',
LeagueMatchHomeGoals = '$home_goals',
LeagueMatchAwayGoals = '$away_goals',
LeagueMatchRap1 = '$rap1',
LeagueMatchRap2 = '$rap2'
WHERE LeagueMatchID = '$matchid'
LIMIT 1
", $connection)
or die(mysql_error());
mysql_query("delete from tplls_scores where matchid = '$matchid' and status = '2'")
or die(mysql_error());
header("Location: $PHP_SELF?sessioid=$sessio");
}
}
?>
<html>
<head>
<title>
QLeague - admin area
</title>
<link rel="stylesheet" type="text/css" href="../css/tplss_admin.css">
</head>
<body>
<?php
include('menu.php');
?>
<table align="center" width="600">
<tr>
<td align="left" valign="top">
<?php
if(!isset($action))
{
?>
<h1>Score conflicts</h1>
<table width="100%" cellspacing="3" cellpadding="3" border="0">
<tr>
<td align="left" valign="top">
Choose one from the list to the right ->
</td>
</tr>
</table>
<?php
}
elseif($action == 'modify')
{
$scoreid = $_REQUEST['scoreid'];
$get_score = mysql_query("SELECT * FROM tplls_scores WHERE id = '$scoreid' LIMIT 1",$connection)
or die(mysql_error());
$data = mysql_fetch_array($get_score);
$get_match = mysql_query("SELECT * FROM tplls_leaguematches WHERE LeagueMatchID = '$data[matchid]' LIMIT 1",$connection)
or die(mysql_error());
$data2 = mysql_fetch_array($get_match);
$get_opponent = mysql_query("SELECT * FROM tplls_opponents WHERE OpponentID = '$data2[LeagueMatchHomeID]' LIMIT 1",$connection)
or die(mysql_error());
$opponent1 = mysql_fetch_array($get_opponent);
$get_opponent = mysql_query("SELECT * FROM tplls_opponents WHERE OpponentID = '$data2[LeagueMatchAwayID]' LIMIT 1",$connection)
or die(mysql_error());
$opponent2 = mysql_fetch_array($get_opponent);
?>
<form method="post" action="<?php echo "$PHP_SELF?sessioid=$sessio" ?>">
<h1>Rule what the score should be !</h1>
<table width="100%" cellspacing="3" cellpadding="3" border="0">
<tr>
<td align="left" valign="top">
Team 1 : <b><?php echo $opponent1['OpponentName'] ?></b><br>
Team 2 : <b><?php echo $opponent2['OpponentName'] ?></b><br>
<?php
if($data[lastedit] == $opponent1[OpponentID]) {
echo "Team 1 says it ended : <b>$data[team21] - $data[team22]</b><br>";
}
else echo "Team 1 says it ended : <b>$data[team11] - $data[team12]</b><br>";
if($data[lastedit] == $opponent2[OpponentID]) {
echo "Team 2 says it ended : <b>$data[team21] - $data[team22]</b><br>";
}
else echo "Team 2 says it ended : <b>$data[team11] - $data[team12]</b><br>";
?>
</td>
</tr>
<tr>
<td align="left" valign="top">
Team 1 wins how many rounds ?:
</td>
<td align="left" valign="top">
<input type="text" name="homer" value="">
<input type="hidden" name="matchid" value="<?php echo $data['matchid'] ?>">
</td>
</tr>
<tr>
<td align="left" valign="top">
Team 2 wins how many rounds ?:
</td>
<td align="left" valign="top">
<input type="text" name="awayr" value="">
</td>
</tr>
<tr>
<td align="left" valign="top">
Team1 reports:
</td>
<td align="left" valign="top">
<textarea name="rap1" cols="50" rows="20"><?
if($data[lastedit] == $opponent1[OpponentID]) echo $data[rap2];
else echo $data[rap1];
?></textarea><br>
</td>
</tr>
<tr>
<td align="left" valign="top">
Team2 reports:
</td>
<td align="left" valign="top">
<textarea name="rap2" cols="50" rows="20"><?
if($data[lastedit] == $opponent2[OpponentID]) echo $data[rap2];
else echo $data[rap1];
?></textarea><br>
</td>
</tr>
</table>
<input type="submit" name="rule_submit" value="Rule!">
</form>
<?php
mysql_free_result($get_score);
}
?>
</td>
<td align="left" valign="top">
<?php
$get_scores = mysql_query("SELECT * FROM tplls_scores WHERE status = '2' ORDER BY id ASC",$connection)
or die(mysql_error());
if(mysql_num_rows($get_scores) < 1)
{
echo '<b>No conflicts at the moment</b>';
}
else
{
echo '<b>Conflicts in database:</b><br><br>';
while($data = mysql_fetch_array($get_scores))
{
echo "<a href=\\"$PHP_SELF?sessioid=$sessio&action=modify&scoreid=$data[id]\\">Matchid $data[matchid]</a><br>\\n";
}
}
?>
</td>
</tr>
</table>
</body>
</html>
<?php
mysql_close($connection);
}
?>