ss90 0 Newbie Poster

hi~ my problem is when i choose the program from the drop-down list then the PEO-ID
will auto display the data that related with program ...then after fill in the form it can click the 'register' button ..

<?php require_once('../../../Connections/admin_db.php'); ?>
<?php require_once('../../../Connections/admin_db.php'); ?>
<?php require_once('../../../Connections/admin_db.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO plo_register (id, p_name, plo_id, peo_id, plo_state, bloom_taxonomy, soft_skill) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['id'], "int"),
                       GetSQLValueString($_POST['p_name'], "text"),
                       GetSQLValueString($_POST['plo_id'], "text"),
                       GetSQLValueString($_POST['peo_id'], "text"),
                       GetSQLValueString($_POST['plo_state'], "text"),
                       GetSQLValueString($_POST['bloom_taxonomy'], "text"),
                       GetSQLValueString($_POST['soft_skill'], "text"));

  mysql_select_db($database_admin_db, $admin_db);
  $Result1 = mysql_query($insertSQL, $admin_db) or die(mysql_error());
}

mysql_select_db($database_admin_db, $admin_db);
$query_insert_plo = "SELECT * FROM plo_register";
$insert_plo = mysql_query($query_insert_plo, $admin_db) or die(mysql_error());
$row_insert_plo = mysql_fetch_assoc($insert_plo);
$totalRows_insert_plo = mysql_num_rows($insert_plo);

$colname_p_name = "-1";
if (isset($_GET['p_name'])) {
  $colname_p_name = $_GET['p_name'];
}
mysql_select_db($database_admin_db, $admin_db);
$query_p_name = sprintf("SELECT p_name FROM p_reg WHERE p_name = %s", GetSQLValueString($colname_p_name, "text"));
$p_name = mysql_query($query_p_name, $admin_db) or die(mysql_error());
$row_p_name = mysql_fetch_assoc($p_name);
$totalRows_p_name = mysql_num_rows($p_name);

mysql_select_db($database_admin_db, $admin_db);
$query_bloom_taxonomy = "SELECT bl_id, bl_name FROM bloom_taxonomy";
$bloom_taxonomy = mysql_query($query_bloom_taxonomy, $admin_db) or die(mysql_error());
$row_bloom_taxonomy = mysql_fetch_assoc($bloom_taxonomy);
$totalRows_bloom_taxonomy = mysql_num_rows($bloom_taxonomy);

mysql_select_db($database_admin_db, $admin_db);
$query_soft_skill = "SELECT category, sk_id FROM soft_skill";
$soft_skill = mysql_query($query_soft_skill, $admin_db) or die(mysql_error());
$row_soft_skill = mysql_fetch_assoc($soft_skill);
$totalRows_soft_skill = mysql_num_rows($soft_skill);

mysql_select_db($database_admin_db, $admin_db);
$query_Recordset1 = "SELECT p_name, peo_id FROM peo_reg";
$Recordset1 = mysql_query($query_Recordset1, $admin_db) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>


<div id="apDiv1">
  <div id="apDiv2"> &gt;&gt; PLO Register&lt;&lt;</div>
  <div id="apDiv9">
    <form action="<?php echo $editFormAction; ?>" method="post" id="form1">
      <table width="493" border="2" cellpadding="2" cellspacing="2">
        <tr valign="baseline">
          <td align="right">Program </td>
          <td><select name="p_name">
            <option value="0">---SELECT---</option>
            <?php
do {  
?>
            <option value="<?php echo $row_p_name['p_name']?>"><?php echo $row_p_name['p_name']?></option>
            <?php
} while ($row_p_name = mysql_fetch_assoc($p_name));
  $rows = mysql_num_rows($p_name);
  if($rows > 0) {
      mysql_data_seek($p_name, 0);
	  $row_p_name = mysql_fetch_assoc($p_name);
  }
?>
          </select></td>
        </tr>
        <tr valign="baseline">
          <td align="right">PLO ID</td>
          <td><input type="text" name="plo_id" value="PLO" size="10" />
          <img src="../images/1301148860_add2-.png" alt="" width="13" height="11" /><a href="#" onclick="MM_openBrWindow('plo_pc.php','PloPC','scrollbars=yes,resizable=yes,width=300,height=300')"> Performance Criteria</a></td>
        </tr>
        <tr valign="baseline">
          <td align="right">PEO ID</td>
          <td><select name="peo_id">
            <option value=""  <?php if (!(strcmp("", $row_p_name['p_name']))) {echo "selected=\"selected\"";} ?>></option>
            <?php
do {  
?>
            <option value="<?php echo $row_Recordset1['peo_id']?>"<?php if (!(strcmp($row_Recordset1['peo_id'], $row_p_name['p_name']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['peo_id']?></option>
            <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
	  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
          </select></td>
        </tr>
        <tr valign="baseline">
          <td align="right">PLO Statatement</td>
          <td><textarea name="plo_state" cols="32"></textarea></td>
        </tr>
        <tr valign="baseline">
          <td height="40" align="right">Bloom Taxonomy</td>
          <td><select name="bloom_taxonomy">
            <option value="0">---SELECT---</option>
            <?php
do {  
?>
            <option value="<?php echo $row_bloom_taxonomy['bl_id']?>"><?php echo $row_bloom_taxonomy['bl_id']?></option>
            <?php
} while ($row_bloom_taxonomy = mysql_fetch_assoc($bloom_taxonomy));
  $rows = mysql_num_rows($bloom_taxonomy);
  if($rows > 0) {
      mysql_data_seek($bloom_taxonomy, 0);
	  $row_bloom_taxonomy = mysql_fetch_assoc($bloom_taxonomy);
  }
?>
          </select><img src="../images/1300976214_help.png" alt="" width="16" height="17" onclick="MM_openBrWindow('info_bloomTaxo.php','InformationOfBloomTaxonomy','toolbar=yes,scrollbars=yes,resizable=yes,width=800,height=800')" /></td>
        </tr>
        <tr valign="baseline">
          <td height="30" align="right">Soft Skill Element</td>
          <td><select name="soft_skill">
            <option value="0">---SELECT---</option>
            <?php
do {  
?>
            <option value="<?php echo $row_soft_skill['sk_id']?>"><?php echo $row_soft_skill['sk_id']?></option>
            <?php
} while ($row_soft_skill = mysql_fetch_assoc($soft_skill));
  $rows = mysql_num_rows($soft_skill);
  if($rows > 0) {
      mysql_data_seek($soft_skill, 0);
	  $row_soft_skill = mysql_fetch_assoc($soft_skill);
  }
?>
          </select>
            <a href="info_sk.php"><img src="../images/1300976214_help.png" alt="" width="16" height="17" onclick="MM_openBrWindow('info_sk.php','InfoOfSk','toolbar=yes,scrollbars=yes,resizable=yes,width=350,height=350')" /></a></td>
        </tr>
        <tr valign="baseline">
          <td align="right">&nbsp;</td>
          <td><input type="submit" value="Register" />
            <label>
              <input type="reset" name="Reset" id="Reset" value="Reset" />
          </label></td>
        </tr>
      </table>
      <input type="hidden" name="id" value="" />
      <input type="hidden" name="MM_insert" value="form1" />
    </form>
    <p>&nbsp;</p>
  </div>
</div>
<p>&nbsp;</p> 
 <p>&nbsp;</p>
<p>&nbsp;</p>
<p>
  <!-- end page -->
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<hr />
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../../../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../../../SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>
<?php
mysql_free_result($insert_plo);

mysql_free_result($p_name);

mysql_free_result($bloom_taxonomy);

mysql_free_result($soft_skill);

mysql_free_result($Recordset1);
?>