This message was edited by tvienti at 2005-7-26 5:45:11
Well it may be a big question to ask, but I can try to point you in the right direction. If I were tackling this problem, this is how I might lay out my tables:
[teachers] - a table of teachers, each with a unique ID, name, any other info you want to store that has a 1-1 relationship with that teacher
[resources] - a table of resources, each with a unique ID, name, group, and subgroup. These fields will be used to render your checkboxes. Group would be "General Resources", "Resources for Social Science", etc. Subgroups would be "Economics", "Government", etc. With this information you could dynamically generate your page of checkboxes, and for the name of each checkbox just use the ID of that resource.
[teachers_resources_xref] - a cross-referencing table (needed since you have a many to many relationship between teachers and resources). This will just have two columns: teachers_id and resources_id. So if teach 1 subscribes to resources 2 3 and 4, there will be three rows: (1,2), (1,3), and (1,4).
When the teacher submits your page, for each checked resource you should get a $_GET[resource_id] = "on". So in your parsing script, just each key where the value = "on" and store that in an array, which will be your list of resources the teacher subscribed to:
$resources = array();
foreach ($_GET as $res_id => $val)
if ($val == "on") $resources[] = $res_id;
At the end of that code you should have an array of $resources which are numbers corresponding to the id field of your resources table. Assuming you already have the teacher's ID somehow - through login or what have you - you just need to build a series of insert statements for each resource ID in the array, which is easy...
// Assumed teacher's ID is already stored in $tid
foreach ($resources as $rid)
{
$query = "INSERT INTO `teachers_resources_xref` VALUES ($tid, $rid);"
// Whatever code you use to execute the query
}
Hope this helps. I intentionally left the mechanics of connecting to and querying the DB because I'm not sure what you do or don't know. If you don't know how to handle databasing in PHP I'd take a look at PHP.net for some really easy to learn functions.
T
: I'm sorry. I misspelled it. The link is:
:
http://www.jamesa3.com/Profiles/profile_start3.html
:
: Out of more than 200 links, I need my database to remember which ones were selected. I need to recall this information later so that on that specific teacher's webpage, only those resources appear which had been checked. I understand that the answer to this problem may be much more of an undertaking than I have the right to ask of anyone.
: