函数变量和php的问题(MySQL的下拉列表)


problem with function variables and php (drop downs with MySQL)

首先,我对编写函数和php的知识非常新手,请耐心等待,感谢您的输入和帮助。

我从MySQL数据库中有三个动态加载的下拉列表。前两个传递一个变量,效果很好。第三次下降需要通过两个值,我很难让它发挥作用。

php:

<select name="COURSE" onChange="get_Results(this.value)">
<option>Select Course</option> 
 <?php 
 require "config.php";
 $CURR=$_GET['CURR'];
 $COURSE=$_GET['COURSE'];
 $query = "SELECT DISTINCT CURR, COURSE FROM UGASU11 WHERE CURR = '$CURR' order by COURSE";
 $result=mysql_query($query);
 while($row=mysql_fetch_array($result)) { ?>
 <option value=<?php echo $row['CURR'].",".$row['COURSE']?>><?php echo $row['COURSE']?></option>
 <? } ?>
 </select>

当用户从第二个下拉输出中选择ADPR时:

<select name="COURSE" onChange="get_Results(this.value)">
<option>Select Course</option>
<option value=ADPR,3110>3110</option>
<option value=ADPR,3520>3520</option>
<option value=ADPR,5910>5910</option>
<option value=ADPR,5990 H>5990 H</option>
</select>

get_Results函数:

function get_Results(CURR,COURSE) {  
 var strURL="/textbookresults.php?CURR="+CURR+"&COURSE="+COURSE; 
 var req = getXMLHTTP();
 if (req) {
  req.onreadystatechange = function() {
    if (req.readyState == 4) { 
    if (req.status == 200) {                    
    document.getElementById('RESULTS_div').innerHTML=req.responseText;
                  } else {
    alert("There was a problem while using XMLHTTP:'n" + req.statusText);
       }
    }            
     }        
req.open("GET", strURL, true); 
req.send(null);
   }
}

textbookresults.hp:中的MySQL查询

$query = "SELECT * FROM UGASU11 WHERE CURR = '$CURR' AND COURSE = '$COURSE'";

我不知道问题出在哪里。我们非常感谢您的帮助。我已经拔头发两天了。

谢谢!

编辑:这是完整的课本。hp:

        <?
        // www.plus2net.com //
        require "config.php";
        $TERM=$_GET['TERM'];
        $CURR=$_GET['CURR'];
        $COURSE=$_GET['COURSE'];
        $PRODUCT_NAME=$_GET['PRODUCT_NAME'];
        $AUTHOR=$_GET['AUTHOR'];
        $PUBLISHER=$_GET['PUBLISHER'];
        $INSTRUCTOR=$_GET['INSTRUCTOR'];
        $PRODUCT_THUMBNAIL=$_GET['PRODUCT_THUMBNAIL'];
        $PRODUCT_CODE=$_GET['PRODUCT_CODE'];
           $query = "SELECT * FROM UGASU11 WHERE CURR = '$CURR' AND COURSE = '$COURSE' order by INSTRUCTOR";
           $qry_result = mysql_query($query) or die(mysql_error());
           $display_string = "<table style='color:#fff;'>";
           while($row = mysql_fetch_array($qry_result)){
           $display_string .= "<tr>";
           $display_string .= "<td colspan=3><b>Instructor: $row[INSTRUCTOR] ($row[CURR] $row[COURSE])</b></td>";
           $display_string .= "</tr>";
           $display_string .= "<tr>";
           $display_string .= "<td>&nbsp;</td>";
           $display_string .= "</tr>";
           $display_string .= "<tr>";
           $display_string .= "<td colspan=2 rowspan=4><img src='"/Merchant5/$row[PRODUCT_THUMBNAIL]'" /></td>";
           $display_string .= "<td><a href='"/product/$row[PRODUCT_CODE].html'" onclick='"return GB_showCenter('Product', this.href, 500, 500, callback_fn)'">$row[PRODUCT_NAME]</a></td>";
           $display_string .= "</tr>";
           $display_string .= "<tr>";
           $display_string .= "<td>Author: $row[AUTHOR]</td>";
           $display_string .= "</tr>";
           $display_string .= "<tr>";
           $display_string .= "<td>Publisher: $row[PUBLISHER] <br /> </td>";
           $display_string .= "</tr>";
           $display_string .= "<tr>";
           $display_string .= "<td style='float:right;'><a href='"/product/$row[PRODUCT_CODE].html'" onclick='"return GB_showCenter('Product', this.href, 500, 500, callback_fn)'"><img src='"/Merchant5/graphics/00000001/images/AddtoBasket.png'" /></a></td>";
           $display_string .= "</tr>";
           $display_string .= "<tr>";
           $display_string .= "<td colspan=3><br /><hr /><br /></td>";
           $display_string .= "</tr>";   
            }
            $display_string .= "</table>";
            echo $display_string;
            ?>

这是我目前得到的回复:

<table style='color:#fff;'></table> 
<option value=<?php echo $row['CURR'],$row['COURSE']?>><?php echo $row['COURSE']?></option>

更改

<option value="<?php echo $row['CURR'].",".$row['COURSE']?>" ><?php echo $row['COURSE']?></option>

这将使此选项的值以逗号分隔

    function get_Results(passedValue) { 
   var args = passedValue.split(",");
   var CUR = args[0];
   var COURSE = args[1];
     var strURL="/textbookresults.php?CURR="+CURR+"&COURSE="+COURSE; 

剩余代码。。。希望这将完全解决问题