Ich möchte die persönl. Statistik des Spielers mit auf die Spielseite einbinden. Das Template dazu ist fertig, nur bekomme ich es nicht gebacken den entsprechenden PHP Abschnitt in die knuffel.php einzubinden. :-?
Der entsprechende Abschnitt ist dieser:
Code: Alles auswählen
//
// get the personal score
//
$sql = "SELECT * FROM ". KNUFFEL_TABLE ." WHERE user = '". $submitid ."'";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not get player information.", "", __LINE__, __FILE__, $sql);
}
$r = $db -> sql_query($sql);
$row = $db -> sql_fetchrow($r);
$playerhighscore = $row['score'];
$playerplayed = $row['played'];
$playeraverage = $row['average'];
$sql = "SELECT COUNT(*) AS total FROM ". KNUFFEL_TABLE ." WHERE score > ". $playerhighscore;
if ( !($result = $db->sql_query($sql)) )
{
message_die('Could not get player position', '', __LINE__, __FILE__, $sql);
}
if ( $total = $db->sql_fetchrow($result) )
{
$playerposition = $total['total'] + 1;
}
$db->sql_freeresult($result);
//
// time to get the top 10
//
$i = 1;
$sql = "SELECT * FROM ". KNUFFEL_TABLE ." WHERE played <> '0' ORDER BY score DESC LIMIT 0,10";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not get top 10 information.", "", __LINE__, __FILE__, $sql);
}
$r = $db -> sql_query($sql);
while($row = $db -> sql_fetchrow($r))
{
$highscorename = $row['name'];
$highscorepoints = $row['score'];
$highscoreplayed = $row['played'];
$highscoreaverage = $row['average'];
$row_class = ( !($i % 2) ) ? $theme['td_class2'] : $theme['td_class1'];
if ( $i < 4 )
{
$highscoreposition = "<b>".$i."</b>";
}
else
{
$highscoreposition = $i;
}
$template -> assign_block_vars('highscore', array(
'POSITION' => $highscoreposition,
'NAME' => $highscorename,
'POINTS' => $highscorepoints,
'PLAYED' => $highscoreplayed,
'AVERAGE' => $highscoreaverage,
'ROW_CLASS' => $row_class));
$i++;
}Code: Alles auswählen
//
// time to get the top 3
//
$i = 1;
$sql = "SELECT * FROM ". KNUFFEL_TABLE ." WHERE played <> '0' ORDER BY score DESC LIMIT 0,3";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not get top 10 information.", "", __LINE__, __FILE__, $sql);
}
$r = $db -> sql_query($sql);
while($row = $db -> sql_fetchrow($r))
{
$highscorename = $row['name'];
$highscorepoints = $row['score'];
$highscoreposition = "<img src=\"knuffel/images/rank/".$i.".gif\" alt=\"\" border=\"0\" />";
$template -> assign_block_vars('highscore', array(
'POSITION' => $highscoreposition,
'NAME' => $highscorename,
'POINTS' => $highscorepoints));
$i++;
}