The PHP + MySQL implementation drop-down box displays the database information & lt; html & gt; & lt; head & gt; & nbsp; & lt; title & gt; Classroomresearch & lt; /title & gt; & lt;/head & gt; & lt; body & gt; & nbsp; & lt; h1 & gt; PHP + MySQL implementation drop-down box displays database information
Classroom research
CRMS-Classroom research
1. I want to enter the classroom number in the first box, and the second box displays the CID content of course2 table in the database in the drop-down box.
This should be wrong. I have no clue and don't know how to implement it. Code details!
2. how can I query data by entering one of the data (that is, no need to fill in two?
------ Solution --------------------
For reference only:
PHP code
Error :". mysql_error (); if (mysql_affected_rows ()> 0) {$ titles = array (); while ($ rows = mysql_fetch_array (MYSQL_ASSOC) {array_push ($ titles, $ rows) ;}}?>
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""; Foreach ($ arrMenu as $ item2) {echo"{$ Item2 ['name']}";} Echo"";}}?>