Jump to content

[Templating] How to display PHP array on template


FUEL

Recommended Posts

need some help sending this query results to a html template.

 

Here's the war_overview.php file

 

/// Scores index

//replay upload path 7kplay
define('REPLAY_UPLOAD_PATH', $phpbb_root_path . 'replays/');

//sql fetch
$dbc = mysqli_connect('*****');

$match_result = array();
$query = 'SELECT *
            FROM ' . war_matches . '
            ORDER BY match_id ASC';
         $result = mysqli_query($dbc, $query);

// loop through array display as html

while ($row = mysqli_fetch_assoc($result))

{
   $match_result[] = $row;
}
foreach ($match_result as $r)
{
  echo $r['game_number'], "\n", $r['match_id'], !more variables here!"<br />";
}
mysqli_close($dbc);

// Output page
page_header($user->lang['INDEX2']);

$template->set_filenames(array(
   'body' => 'battle_results.html')
);

page_footer();

?>

 

this will display: the result on top of the site even above the headers.

 

Deleting this out of the .php file and putting it on the battle_results.html template file doesnt work.

 

foreach ($match_result as $r)
{
  echo $r['game_number'], "\n", $r['match_id'], !more variables here!"<br />";
}

anyone can help me?

that doesnt work. stays the same.

 

I think this is how i mean it should work, this example however does NOT work but indicates what i mean by sending the results to the template.

 

// Assign battle_results specific vars
$template->assign_vars(array(
'BATTLE_RESULTS' 	=> foreach ($match_result as $r){echo $r['game_number'], "\n", $r['match_id'], "<br />";},
);

 

then i can simply write: {BATTLE_RESULTS} anywhere on my template .html to have it display the war_overview

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.