FUEL Posted February 24, 2010 Share Posted February 24, 2010 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? Link to comment https://forums.phpfreaks.com/topic/193201-templating-how-to-display-php-array-on-template/ Share on other sites More sharing options...
teamatomic Posted February 24, 2010 Share Posted February 24, 2010 name it battle_results.php and see what happens HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193201-templating-how-to-display-php-array-on-template/#findComment-1017384 Share on other sites More sharing options...
FUEL Posted February 24, 2010 Author Share Posted February 24, 2010 that doesnt work, the template file battle_results.html must stay .html! (the header and footer stop working this .php file is a part of a bigger file, more all functionality is lost if the T file changes to .php.) Link to comment https://forums.phpfreaks.com/topic/193201-templating-how-to-display-php-array-on-template/#findComment-1017435 Share on other sites More sharing options...
teamatomic Posted February 24, 2010 Share Posted February 24, 2010 What happens if you move the code to above page_footer() so it outputs after the results page is included? HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193201-templating-how-to-display-php-array-on-template/#findComment-1017444 Share on other sites More sharing options...
FUEL Posted February 24, 2010 Author Share Posted February 24, 2010 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 Link to comment https://forums.phpfreaks.com/topic/193201-templating-how-to-display-php-array-on-template/#findComment-1017489 Share on other sites More sharing options...
FUEL Posted February 24, 2010 Author Share Posted February 24, 2010 here is another code that should probably be included to assign the variables. but i have no clue how to work this command $template->assign_block_vars (my code here?) Link to comment https://forums.phpfreaks.com/topic/193201-templating-how-to-display-php-array-on-template/#findComment-1017502 Share on other sites More sharing options...
teamatomic Posted February 24, 2010 Share Posted February 24, 2010 do a test $block='this is a test<br>for block vars'; $template->assign_block_vars ($block) What happens? HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193201-templating-how-to-display-php-array-on-template/#findComment-1017607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.