Hi and TNX for stop here
Im making a high score table for a game making use of PHP/Mysql and flash and I found this tutorial:
http://www.glenrhodes.com/flashgamecoders/modules.php?op=modload&name=News&file= article&sid=8
But In this tutorial I vae the rank,Player name, Score but I want to put also the country, What I have now is DB with the new table and I put the data (country) in the database but Im having troubles pulling this new entry from the Grid someone can help me ?
Im sure that the problem is from the PHP side:
hiscore.php
<?php require_once('hsconfig.php'); ?>
<?php
$HSDB = mysql_pconnect($hostname_HSDB, $username_HSDB, $password_HSDB) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_HSDB, $HSDB);
if (isset($_POST['action']))
$holder = $_POST;
else
$holder = $_GET;
$action = $holder['action'];
$viewmode = $holder["viewmode"];
if ($viewmode == "admin") echo "Action is :" . $action . "<br/>";
if ($action == "getBottom")
$order = "ASC";
else
$order = "DESC";
if ($action == "getTop" || $action == "getBottom")
{
if (! preg_match("/^[0-9]+$/", $holder[limit])) { $holder[limit] = 10; }
$limit = $holder['limit'];
$gameID = $holder['gameID'];
$query_Recordset1 = "SELECT playername, score, country_db, number_db FROM " . $table_HSDB . " WHERE gameid = '" . $gameID . "' ORDER BY score " . $order;
if ($viewmode == "admin") echo $query_Recordset1;
$Recordset1 = mysql_query($query_Recordset1, $HSDB) or die(mysql_error());
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$topplayers = array();
while ($results = mysql_fetch_array($Recordset1))
{
if (! $topplayers[$results['playername,']])
{
$topplayers[$results['playername']] = $results['score'];
}
if (count($topplayers) == $limit) { break; }
}
$cnt = 1;
if ($viewmode == "admin" || $viewmode == "site")
{
?>
<table border="1">
<tr>
<th>Rank</th>
<th>Name</th>
<th>Score</th>
</tr>
<?php
if ($holder['dupes'] == "false")
{
foreach ($topplayers as $playername => $score)
{
?>
<tr>
<td><?php echo $cnt; ?></td>
<td><?php echo $playername; ?></td>
<td><?php echo $score; ?></td>
</tr>
<?php
$cnt++;
}
}
else
{
if ($totalRows_Recordset1 > 0) mysql_data_seek($Recordset1, 0);
while ($results = mysql_fetch_array($Recordset1))
{
?>
<tr>
<td><?php echo $cnt; ?></td>
<td><?php echo $results[playername];?></td>
<td><?php echo $results[score];?></td>
</tr>
<?php
$cnt++;
if ($cnt > $limit) break;
}
}
?>
</table>
<?php
}
else if ($viewmode == "flash")
{
$cnt = 0;
if ($holder['dupes'] == "false")
{
foreach ($topplayers as $playername => $score)
{
echo
"&n" . $cnt . "=" . $playername .
"&s" . $cnt . "=" . $score .
"&c" . $cnt . "=" . $country_db .
"&d" . $cnt . "=" . $number_db;
$cnt++;
}
}
else
{
mysql_data_seek($Recordset1, 0);
while ($results = mysql_fetch_array($Recordset1))
{
echo
"&n" . $cnt . "=" . $results[playername] .
"&s" . $cnt . "=" . $results[score] .
"&c" . $cnt . "=" . $results[country_db] .
"&d" . $cnt . "=" . $results[number_db];
$cnt++;
if ($cnt > $limit) break;
}
}
}
mysql_free_result($Recordset1);
}
else if ($action == "addNew")
{
$userID = $holder['userID'];
$gameid = $holder['gameID'];
$score = $holder['score'];
$country_db = $holder['country_db'];
$number_db = $holder['number_db'];
$query_Recordset1 = "INSERT INTO " . $table_HSDB . " (
gameid,
playername,
score,
country_db,
number_db
) VALUES (
'" . $gameid . "',
'" . $userID . "',
'" . $score . "',
'" . $country_db . "',
'" . $number_db . "'
)";
$Recordset1 = mysql_query($query_Recordset1, $HSDB) or die("&result=fail&reason=".mysql_error());
if ($viewmode == "admin") echo $query_Recordset1;
echo "&result=success&";
}
?>