How to insert a custom value to the database

Source: Internet
Author: User
Choose to insert a value to the database account: you have 20 options and 5 options. Class: only one class can be selected. Then these five subjects and classes will be written into the database. It is to implement such a simple function, although I made it, but I think it is not appropriate. Now I divide my subjects and classes into two tables. It is equal to two insert statements. the IDs of the two insert statements are AUTO_INC values.
Subjects: there are 20 options, and you can select 5.
Class: only one class can be selected.

Then these five subjects and classes will be written into the database. It is to implement such a simple function, although I made it, but I think it is not appropriate.

Now I divide my subjects and classes into two tables. It is equal to two insert statements. the id of the two insert statements is AUTO_INCREMENT. Therefore, in theory, their corresponding id should also be able to match the number. But this is obviously unreasonable.

Second, in this case, the 20 values are actually written into the insert section, but the values are written into the selected values, and those that are not selected are left blank. Then all the output results are output to all the 20 values, but some are empty. so at last, only five values are output, but 20 values are actually output, the other 15 are empty.

PHP code
  
  


------ Solution --------------------
I don't quite understand your needs. if I do this, I will build a Cortana.
If this parameter is selected, the id of the subject is saved as a string, for example, 1, 2, and 3. the selected class also saves the same table.
Show select * from subject where id in (1, 2, 3) when selecting a subject)

------ Solution --------------------
Three tables:
Cool:
Id
Name

Class:
Id
Name

Optional table:
Id
Account ID (account id eg: 1, 2, 3)
Class ID (saved class id)

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.