Home > Backend Development > PHP Tutorial > PHP+MySQL实现下拉框显示数据库信息解决思路

PHP+MySQL实现下拉框显示数据库信息解决思路

WBOY
Release: 2016-06-13 10:24:52
Original
1060 people have browsed it

PHP+MySQL实现下拉框显示数据库信息


  Classroom research



 

CRMS - Classroom research



 

 
 
 
 
 
 


 

 
 
 
 
Classroom ID
Course ID

 

 




1、我希望在第一个框输入课室号,第二框通过下拉框显示数据库中course2表的CID的内容。
这应该就是不对的,毫无头绪,不知道怎么实现。求详细代码!
2、怎样实现填写其中一个数据(即不用填两个)就可以查询数据?


------解决方案--------------------
仅供参考:
PHP code
<?php /* Created on [2012-5-16] */#查询标题信息$sql="select * from table";    $res=mysql_query($sql);    if(!$res) die("SQL: {$sql} <br>Error:".mysql_error());    if(mysql_affected_rows() > 0){        $titles = array();        while($rows = mysql_fetch_array(MYSQL_ASSOC)){            array_push($titles,$rows);        }    }?>
Copy after login
=$row_Recordset_task['csa_title']?>
<script>//Ajaxvar xmlHttp; function createXMLHttpRequest() { if(window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } } function record(id){ createXMLHttpRequest(); url = "action.php?id="+id+"&ran="+Math.random(); method = "GET"; xmlHttp.open(method,url,true); xmlHttp.onreadystatechange = show; xmlHttp.send(null); } function show(){ if (xmlHttp.readyState == 4){ if (xmlHttp.status == 200){ var text = xmlHttp.responseText; document.getElementById("s2").innerHTML = text; }else { alert("response error code:"+xmlHttp.status); } } }</script>Error:".mysql_error()); if(mysql_affected_rows() > 0){ $arrMenu=array(); while($rows = mysql_fetch_array(MYSQL_ASSOC)){ array_push($arrMenu,$rows); } } mysql_close(); if(!empty($arrMenu)){ echo ""; }}?>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template