PDA

View Full Version : Created a vB Table, PHP Page and Template; Now What?


TMSBrad
06-01-2010, 04:58 PM
I created a table called hall_of_fame with the following fields:


id
name
year
bio
I created a PHP page called hall.php that looks like this:

<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT', 'hall');
define('CSRF_PROTECTION', true);
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('hall',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

$navbits = construct_navbits(array('' => 'Mustang Hall of Fame'));
$navbar = render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'Mustang Hall of Fame';

// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater = vB_Template::create('hall');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());

?>


I created a template called hall that l want to populate using data from hall_of_fame.

I want a dropdown menu that includes all of the values from hall_of_fame.name. When a name is selected, an image on the page should be replaced with [hall_of_fame.id].jpg, and other text elements should be updated with data from the hall_of_fame record.

How do I do that?