PHP存储PHP变量中选定的HTML表单项

时间:2014-02-24 18:52:09

标签: php jquery html mysql dynamic

我正在创建一个储物柜注册Web应用程序。我有一个名为studentdata.php的页面,它显示从搜索查询中获取的学生信息(已完成)。

学生数据页面显示姓名,电子邮件,学生ID,课程/学习领域。旁边是一个具有另一种形式的div。该表单有一个下拉列表,显示该学生可用的储物柜。是什么让储物柜可用: 它被分配给他们的程序并且studID为0(意味着没有学生分配给它)。

我想要的是什么:当我在下拉列表中选择其中一个储物柜时,它会动态显示该储物柜的组合以及该储物柜所在的部分(即1A)位于下方的两个输入字段中下拉列表 - 此信息存储在我最初检索更衣柜号码的表格中。

以下是代码:

<?php
    $url = $_SERVER['REQUEST_URI'];
    $studID = substr($url, strpos($url, "=") + 1);

$db_handle = mysql_connect("localhost", "root", "pickles") or die("Error connecting to database: ".mysql_error());
    /*
        localhost - it's location of the mysql server, usually localhost
        root - your username
        third is your password

        if connection fails it will stop loading the page and display an error
    */

    mysql_select_db("lockers",$db_handle) or die(mysql_error());
    /* tutorial_search is the name of database we've created */

$result = mysql_query("SELECT * FROM students WHERE studID = $studID"); 
    ?>
<div class="container">
  <header> <a href="#"><img src="images/headmast.png" alt="Insert Logo Here" width="686" height="180" id="Insert_logo" /></a> </header>
  <div id="data1">
  <form id ="studData" name="studData" action="update.php" medthod="post">
    <fieldset>
      <legend>Student Details</legend>
      <?php
  while($row = mysql_fetch_array($result)) 
  { 
  echo '<ol>';
   echo '<li>';
  echo '<label for=studid>Student ID</label>';
  echo '<input id=studid name=studid type=text value='.$row['studID'].'>';
  echo '</il>';
  echo '<li>';
  echo '<label for=fname>First Name</label>';
  echo '<input id=fname name=fname type=text value='.$row['firstName'].'>';
  echo '</il>';
  echo '<li>';
  echo '<label for=fname>Last Name</label>';
  echo '<input id=lname name=lname type=text value='.$row['lastName'].'>';
  echo '</il>';
  echo '<li>';
  echo '<label for=email>Email</label>';
  echo '<input id=email name=email type=text value='.$row['email'].'>';
  echo '</il>';
  echo '<li>';
  echo '<label for=progam>Program</label>';
  echo '<input id=progam name=progam type=text value='.$row['program'].'>';
  echo '</il>';
  echo '</ol>';
  $program = $row['program'];  //get name of program 
  } 
  ?>
      <input type="submit" value="Update" class="fButton"/>
    </fieldset>
  </form>

  <form id="locker" name="locker" action="" method="post" >
    <fieldset>
      <input type="button" onclick="show()" value="Add Locker"/>
      <div id="addlocker" style="display:none;"> 
      <!--
      query lockers where $program = program parsed in & student id is equal to 0 (this makes it available)
      get select list to 10
      populate select list    -->  <br/>
      <legend>Lockers Available: </legend>
      <select size="10" name="lockerSelect" multiple="yes" style="width:200px;">
      <?php
      $result1=mysql_query("SELECT * FROM lockers WHERE progName = '$program' && studID = 0") or die($result1."<br/><br/>".mysql_error());
      while($row1 = mysql_fetch_array($result1)) 
  {
     echo '<option value=\"'.$row1['lockerScan'].'">'.$row1['lockerNo'].'</option>';
  }
  echo '</select>';

      ?>
      </div><!--end of add locker section-->
    </fieldset>
  </form>

0 个答案:

没有答案