Getting certain info in variables

I have a form where a user selects up to 4 options out of 50 or so possible answers. They are possible teaching endorsments, and a teacher may have no more than 4. They are credential codes ie 001, 002, 003 etc. I have my database setup so that these codes are the names in the database. When they select the answers an X gets put in the database. Now my question, What would be an efficient way of getting the 4 entries in the database with an X into variables?

Thanks for any tips.

I don’t understand your database design. Please show your create statement and reexplain with examples.

Ok I just have a table the name of the fields are codes (100, 101, 102 etc)
On the form they have the option of checking these codes and if they do check it an X gets put in the database for that field (ie if they check the 100 box then and X gets put into the table in the 100 field).

A person will only choose 4 out of 50 of these options. I am creating a page that will list the ones that they chose only (ie if they chose 100,200,303 and 404 boxes then I will just list those on the page) My problem is I do not know how to get just the fields that the user selected (with an X in it).

Thanks.

"My problem is I do not know how to get just the fields that the user selected (with an X in it). "

No, your problem is your database design. Instead, do it like this:
Have four columns: num1,num2,num3,num4
Put the four checked numbers in these columns. Problem solved (I assume you know how to do the query now).

Ok assuming that would work (have to think it through some more) how would I get num1 -num4 populated with the 4 they choose?

thanks!

I really don’t see the problem. It is a very simple query.
“INSERT INTO tabelname (‘num1’,‘num2’,‘num3’,‘num4’) VALUES (’$num1’,’$num2’,’$num3’,’$num4’)”;

I may have a small syntax error, but that is the theory right there.

I understand the sql side of it but if I have a list of 50 or so options how do I get the options they selected into the num variables.

Best thing to do when you need help: Google for others with the same problems. You need to know how to get the checkbox info into PHP:
http://www.webmasterworld.com/forum88/3620.htm

In other words, I’m currently too lazy to parse all that for you, I think some reading will do you good.

This is, of course, what I do with problems - I don’t know the answer to that many off by heart, but Google and php.net are powerful tools. I can usually solve the problem pretty quickly with them before resorting to asking the gurus like Bane and Monk.

Thanks.

Sponsor our Newsletter | Privacy Policy | Terms of Service