Jump to content

An easy way to do this?


eugeniu

Recommended Posts

I'm creating a quiz/flashcard program with somewhere over a hundred questions. The questions are organized into groups of five or less, with each group having an ID. So my database for the questions is like:

 

Question1 | Group# | Answer1

Question2 | Group# | Answer2

Question3 | Group# | Answer3

Et cetera...

 

I'm planning on creating options in my settings page to let the user pick exactly what group he or she wants to receive questions from, and to have those settings saved on their account, in their account entry on the database. My problem is that I don't want to have to make a field for each group on my users table, because I'd then end up with dozens of fields.

 

So is there any way I could define what groups I want to use in one field on a table? Thanks.

Link to comment
Share on other sites

Create a table for group types

CREATE TABLE  `your_database`.`tbl_group_type` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` TEXT NOT NULL
) ENGINE = MYISAM

Create a log db for users->groups

CREATE TABLE  `your_database`.`tbl_groups` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`userid` INT NOT NULL ,
`groupid` INT NOT NULL
) ENGINE = MYISAM

log all the groups into the group_type table and propigate the users table with your information, when your pulling out use somthing similar to

SELECT * FROM `tbl_groups` WHERE `userid` = '".$the_user_id."'

 

hope this helps

Link to comment
Share on other sites

Nothing their both tables, its just me , When describing a database I say a table is static information & a logging db records data(dynamic), but they are both tables, lol dont listen to my excentricities.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.