<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
	<title>FMPro XML</title>
	<style type="text/css">
	<!--
		body { font-family: verdana; }
		td, th { color: white; }
		.header { background: blue; }
		.odd { background: silver; }
		.even { background: black; }
	-->
</style>
</head>
<body>

<?php

# Include the RAX library
include( "prax.inc"        );
include( "FMProClient.php" );

function oddOrEven($num)
{
	if ($num % 2 != 0)
	{
		$result = "odd";
	}
	else
	{
		$result = 'even';
	}
	
	return $result;
}

function showrecords($url)
{
	# Create a new RAX object
	$rax = new RAX();

	# Open the XML document
	$rax->open($url);

	# Select the individual record delimiter
	$rax->record_delim = 'ROW';
	
	# Start parsing the XML document
	$rax->parse();

	# Read the first record
	if( $rec = $rax->readRecord())
	{
	$row = 1;

	$names 	= $rec->getFieldNames();

	print "<table cellpadding=\"5\" cellspacing=\"0\">\n\t<tr>\n";
	while ($name = array_shift($names))
	{
		print "<th class=\"header\">".$name."</th>\n";
	}
	print "\t</tr>\n\t";

	print "<tr>\n";

	while ( $rec ) 
	{
	
		$class = oddOrEven($row);
		
		print "<tr>";
		$values = $rec->getFields();
		while ($value = array_shift($values))
		{
			print "<td class=\"".$class."\">".$value."</td>\n";
		}
		print "</tr>";
		$rec = $rax->readRecord();
		$row++;
	}
	print "</table>";
	}
	else
	{
		print "<p>There were no results returned. Either an error occured on the FMPro Server, or no records matched your query.</p>";
	}
}

?>

<h1>All Records</h1>

<?php 
$xml = getAllRecords("phonelist.fp5");
showrecords($xml); 
?>

</body>
</html>