<?php

//get table fields for select box

$table=$_GET['table'];

require ("./include/folio_config.php");

$dbname=$globalConfig['dbname'];
$dbprefix=$globalConfig['dbprefix'];

require ("./include/connect_db.php");
mysql_select_db($dbname, $link) or die("couldn't select database");

$detailsresult=mysql_query("SELECT * FROM ".$dbprefix."$table ");
$detailsresultrow=mysql_fetch_array($detailsresult);
$numfields=mysql_num_fields($detailsresult);

	$i=0;


  $json = '['; // start the json array element
  $json_names = array();
  
	while($i<$numfields){
		$meta = mysql_fetch_field($detailsresult, $i);
		$fieldname=$meta->name;
		$fieldvalue=$detailsresultrow[$i];
		$json_names[] = "{optionValue: '$fieldname', optionDisplay: '$fieldname'}";
		$i++;
	}
  
  $json .= implode(',', $json_names); // join the objects by commas;
  $json .= ']'; // end the json array element
  echo $json;



?>