<?php

  /* Allows user to choose a topic from the SEELS database, 
    after having specified an instrument and a conceptual area.  It's the third
    page of the SEELS search process. */

  	$instrIDParam = $_POST['InstrumentID'];
  	$conceptAreaIDParam = $_POST['ConceptualAreaID'];
  	$topicIDParam = $_POST['TopicID'];

   // initialize database connections
	$conn = new mysqli('localhost', 'seels_web', 'seels', 'seels');
	if(mysqli_connect_errno()) {
		 echo "Connection Failed: " . mysqli_connect_errno();
		exit();
	}

	// Get info from database
	$instrName = "";
	$query = "SELECT InstrumentName FROM Instruments WHERE InstrumentID='" . $instrIDParam . "'" ;
	$result = $conn->query($query);	
	if ($result) { 
		$row = $result->fetch_assoc();
		$result->free();
		$instrName = $row["InstrumentName"]; 
	}

	$conceptAreaName = "";
	$query = "SELECT ConceptualAreaName FROM ConceptualAreas WHERE ConceptualAreaID='" . $conceptAreaIDParam . "'" ;
	$result = $conn->query($query);	
	if ($result) { 
		$row = $result->fetch_assoc();
		$result->free();
		$conceptAreaName = $row["ConceptualAreaName"]; 
	}
		
	$query = "SELECT TopicID, TopicName FROM Topics WHERE ConceptualAreaID='" . $conceptAreaIDParam . "' ORDER BY TopicName";
	$result = $conn->query($query);	
	
?>

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html lang="en">

<head>
<title>SEELS Data Tables: Choose Topic (text version)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link rel="stylesheet" type="text/css" href="../seels.css" title="Seels css stylesheet">
<link href="displayTable.php" rel=next rev=prev>


<script src="../../javascript/submitToURL.js"></script>

<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//-->
</script>

</head>

<body>

<br><br>

<p><a href="#begintext" title="Go to the beginning of the text on this page">Skip Navigational Links</a></p>

<p class="center">| <a href="datatableOverview.htm" title="Data Tables Overview Page">Data 
  Tables Overview</a> | <a href="chooseInstrument.php" title="Step 1: Choose Data Source Page">Step 
  1: Choose Data Source</a> | <a href="chooseConceptArea.php" title="Step 2: Choose Conceptual Area Page">Step 
  2: Choose Conceptual Area</a> | <span class="black">Step 3: Choose Topic</span> 
  | <a href="displayTable.php" title="Selection Result Page">Step 4: Selection 
  Result</a> | <a href="../table_howto.html" title="How to Read SEELS Tables Page">How 
  to Read SEELS Tables</a> | <a href="../txindex.htm" title="SEELS Home Page">SEELS 
  Home & News</a> |</p>

<a name="begintext"></a>

<h1 class="center">DATA TABLES</h1>
<h2 class="center">Step 3: Choose Topic</h2>

<p>&nbsp;</p>

      <form name="chooseTopic" method="post" action="displayTable.php">
      <input type=hidden name="InstrumentID" value="<?php echo $instrIDParam ?>">
      <input type=hidden name="ConceptualAreaID" value="<?php echo $conceptAreaIDParam ?>">
        <p>You 
          chose <strong><?php echo $instrName ?></strong> as your Data Source and <strong><?php echo $conceptAreaName ?></strong> 
          as your Conceptual Area. To change the Conceptual Area, click Back below.</p>
        <p>Otherwise, 
          choose from the Topics available for <strong><?php echo $instrName ?>, <?php echo $conceptAreaName ?></strong> 
          and then click Next:</p>
		  
		  <blockquote>
		  <label for="topics">Topics:</label>
  		  <select name="TopicID" id="topics">
  		  
          <?php
          	  $topicID = "";
              if ($result) {
     			 while($row = $result->fetch_assoc()) {
     			 	$topicID = $row["TopicID"];
     			 	echo "<option value='" . $topicID . "'";
     			 	if  (($topicIDParam != null) && $topicIDParam == $topicID) {
     			 		echo " selected";
     			 	}
     			 	echo ">" . $row["TopicName"] . "</option>";
     			 }
    		} else {
      			echo mysql_error();
    		}
    		$result->free();
    		$conn->close();
        ?>
          
          
        </select>
		  </blockquote>
      	<p>
        <label for="nextpage">Go to Next Page:</label>
        <input type="submit" name="Next" value="Next" id="nextpage">
		<br>
	  	<label for="goback">Go Back:</label>
        <input type="button" name="Back" value="Back" id="goback" onClick="submitToURL('chooseTopic','chooseConceptArea.php');"><br>
      	</p>
      </form>

<br><br>	
	
<p class="center">| <a href="datatableOverview.htm" title="Data Tables Overview Page">Data 
  Tables Overview</a> | <a href="chooseInstrument.php" title="Step 1: Choose Data Source Page">Step 
  1: Choose Data Source</a> | <a href="chooseConceptArea.php" title="Step 2: Choose Conceptual Area Page">Step 
  2: Choose Conceptual Area</a> | <span class="black">Step 3: Choose Topic</span> 
  | <a href="displayTable.php" title="Selection Result Page">Step 4: Selection 
  Result</a> | <a href="../table_howto.html" title="How to Read SEELS Tables Page">How 
  to Read SEELS Tables</a> | <a href="../txindex.htm" title="SEELS Home Page">SEELS 
  Home & News</a> |</p>


    <p>last update: 02/03<br>
  2003 SRI International</p>

<ul><li><a href="http://bobby.watchfire.com/" title="Bobby's Home Page">
		<img src="../approved_aaa.gif" alt="Bobby WorldWide Approved AAA" width="88" height="31"></a></li> 
	<li><a href="http://jigsaw.w3.org/css-validator/">
  		<img style="border:0;width:88px;height:31px"
       	src="../valid-css.gif" 
       	alt="The CSS used for this site passed the World Wide Web Consortium's (W3C) validation service."></a></li>
    <li><a href="http://validator.w3.org/">
		<img border="0"
         src="../valid-html40.gif"
         alt="The HTML 4.0 used for this site passed the World Wide Web Consortium's (W3C) validation service." height="31" width="88"></a></li>
</ul>
 
  

</body>

</html>
