<?php
// Set MIME type for XML grammar fomat
header('Content-type: application/grammar+xml');
//Include sub class
require ('createGrammar.php');
// Database access inforation
$host = "";
$user = "";
$password = "";
$database = "";
// Make connection to databse
$db = mysql_connect($host, $user, $password);
// Select database, submit query and collect results
mysql_select_db($database);
$query = "SELECT ch_name, ch_num FROM radio WHERE type='Country'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
mysql_close($db);
// Instantiate arrays to pass to simpleGram function
$name_array = array();
$channel_array = array();
// Populate arrays with result of database query
for ($i=0; $i<$num_results; $i++)
{
$row = mysql_fetch_row($result);
array_push($name_array, $row[0]);
array_push($channel_array, $row[1]);
}
// Create new grammar object
$page = new createGrammar;
// Set rule names for grammar
$page->setRoot("primary");
$page->setRuleID("primary");
// Set slot name for return value
$page->setSlot("first");
// Set language (optional - default is US English)
$page->setLang("es-US");
// Pass channel arrays to simpleGram function
$page->simpleGram($name_array, $channel_array);
?>
|