-2
I’m trying to organize a ranking with some data from my DB in Mysql. I need to collect the data displayed in Query but does not come at all.
See the image of the query with the data.
Where I’m trying to enter the data, in the level and Lider case (player_name)
My php SELECT:
// Player Top Guilds (guilds.php)
$cron_p7 = '<?PHP $guilds = array(';
$total7 = 0;
if ($cron_7=mysqli_query(server_player(), "SELECT guild.name, guild.level, guild.ladder_point, player.name AS player_name, player_index.empire AS guild_empire FROM guild LEFT JOIN player ON player.id = guild.master LEFT JOIN player_index ON player_index.id=player.account_id ORDER BY guild.ladder_point DESC, guild.name ASC;"))
while ($cron_r7=mysqli_fetch_object($cron_7)){
$total7++;
$empr = ($cron_r7->guild_empire)?$cron_r7->guild_empire:1;
$cron_p7 .= ' '.$total7.' => ["'.$cron_r7->name.'", '.$empr.', '.$cron_r7->ladder_point.'],';
}
$cron_p7 .= ');';
$cron_f7 = fopen(s('cron')."guilds.php", "w");
fwrite($cron_f7, $cron_p7);
fclose($cron_f7);
echo "Cron Ejecutado <b>guilds.php</b>...<br>\n";
My php with the results:
<?PHP $start_count += 10; } ?>
</div>
<table id="full_ranking_table">
<tr class="full_ranking_table_titles_row">
<td class="full_ranking_table_title_position">#</td>
<td class="full_ranking_table_title_name"><?=l(52);?></td>
<td class="full_ranking_table_title_name_lider">Level</td>
<td class="full_ranking_table_title_name_lider">Lider</td>
<td class="full_ranking_table_title_kingdom"><?=l(53);?></td>
<td class="full_ranking_table_title_points"><?=l(57);?></td>
</tr>
<?PHP for($i = $start + 1; $i <= $stop; $i++){ ?>
<tr class="full_ranking_table_row <?=($i == GPage(4))?"highlighted_playername":"";?>">
<td id="p<?=$i;?>" class="full_ranking_rank <?=($i>5)?"":"top_rank";?>"><?=($i>5)?$i:"";?></td>
<td class="full_ranking_playername"><?=$guilds[$i][0];?></td>
<td class="full_ranking_playername"><?=$guilds[$i][1]?></td>
<td class="full_ranking_playername"><?=$guilds[$i][1]?></td>
<td class="full_ranking_<?=$guilds[$i][1]?>_kingdom"></td>
<td class="full_ranking_points"><?=$guilds[$i][2]?></td>
</tr>
<?PHP } ?>
See the example of the ranking:
Obs: this <?=$guilds[$i][1]?>
in the field that should contain the column id because I can’t get to the correct ID, and I put it as an example. I’ve tried using a print_r($guilds)
to try to locate the information and not pull the data.
At first you do
$cron_p7 = '<?PHP $guilds = array(';
and soon after you overwrite$cron_p7
withif ($cron_7=mysqli_query(...
and continues to overwrite$cron_p7
inwhile ($cron_r7=mysqli_fetch_object($cron_7)
you have to create own variables to receive these objects.– Augusto Vasques
Thanks a lot for the tip I got :) $cron_p7 .= ' '.$total7. ' => ["'. $cron_r7->name. '", '.$Empr. ', '.$cron_r7->ladder_point. ', "'. $cron_r7->player_name. '", "'. $cron_r7->level.'"],';
– Renato Assis