PHP Classes

File: grammar_test2_php

Recommend this page to a friend!
  Classes of Mark Headd  >  PHP Grammar  >  grammar_test2_php  >  Download  
File: grammar_test2_php
Role: Example script
Content type: text/plain
Description: Moderately complex grammar example
Class: PHP Grammar
Create speech recognition grammar W3C XML files
Author: By
Last change:
Date: 17 years ago
Size: 1,283 bytes


Class file image Download

// 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
$query = "SELECT ch_name, ch_num FROM radio WHERE type='Country'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);

// 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

// Set slot name for return value

// Set language (optional - default is US English)

// Pass channel arrays to simpleGram function
$page->simpleGram($name_array, $channel_array);


For more information send a message to info at phpclasses dot org.