How to use the database to output the corresponding data (the description may be related to the problem, for details)

Source: Internet
Author: User
How can we use a database to output the corresponding data (which may be a problem to describe )? The current code is attached at the end. If you want to add an office name, you can directly use insert & nbsp; into to enter the officename table. However, here, how does the officename and officecode output the corresponding data through the database (which may be a problem to describe )?
The current code is attached at the end. If you want to add an office name, simply use insert into to enter the table officename.
However, here the officename and officecode are written to death through JS. If you add them in this way, there will be a problem with the corresponding relationship between the two. the newly added data does not have the corresponding officecode. This requires you to manually add it in the js code. it seems unreasonable.

Therefore, I want to read data directly from the database instead of using js. the officename table creates two fields: name and code.
It is feasible to directly read the database and match the two. We recommend that you have an instance. thank you.





Function setofficecode ()
{
// Obtain the value of officename/officecode
Var officename = document. getElementById ("officename"). value;
Var o = document. getElementById ("officecode ");
// Condition determination
If (officename = "XX Office "){
O. value = "101 ";
}
Else if (officename = "YY Office "){
O. value = "201 ";
}
Else if (officename = "ZZ Office "){
O. value = "301 ";
}

}
Script





------ Solution --------------------
Modified
 
  
 


 
 











Office name

Include ('Conn. php ');
$ SQL = "select * from officename ";
$ Query = mysql_query ($ SQL );
While ($ result = mysql_fetch_array ($ query )){
?>
  ">
  }
?>

Office number

 

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.