PHP + MySQL implementation drop-down box shows the solution to database information

Source: Internet
Author: User
Tags php foreach
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"";}}?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.