Hi,
I am new bie to Games development. Basically this script is to post and retrieve the high score for the flash games. I am trying to use the 'hiscore.php' script to submit and retrieve the high scores. It is working fine. Now I am trying to add 2 extra fields, ie. country and age. I have modified the database accordingly and when the score is submitted the playername, country, age and score fields are being submitted properly. I have seen the values populating in the table.
Now, I am unable to retrieve the country and the age. The Rank, Name and Scores are being displayed properly. The other two fields (coutry, age) are showing blank. The new data field names are 'country' and 'age' respectively.
Can some one help me to modify the following code to suit my requirements please.
Thanks,
JAg
<?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 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;
$cnt++;
}
}
else
{
mysql_data_seek($Recordset1, 0);
while ($results = mysql_fetch_array($Recordset1))
{
echo "&n" . $cnt . "=" . $results[playername] . "&s" . $cnt . "=" . $results[score];
$cnt++;
if ($cnt > $limit) break;
}
}
}
mysql_free_result($Recordset1);
}
else if ($action == "addNew")
{
$userID = $holder['userID'];
$gameid = $holder['gameID'];
$score = $holder['score'];
$query_Recordset1 = "INSERT INTO " . $table_HSDB . " (gameid, playername, score) VALUES ('" . $gameid . "','" . $userID . "','" . $score . "')";
$Recordset1 = mysql_query($query_Recordset1, $HSDB) or die("&result=fail&reason=".mysql_error());
if ($viewmode == "admin") echo $query_Recordset1;
echo "&result=success&";
}
?>[COLOR=red]red[/COLOR]