Forums

This topic is locked

PHP & MySQL - Nested Forms?

Posted 23 Apr 2005 03:26:19
1
has voted
23 Apr 2005 03:26:19 Stu Helm posted:
Hi folks
I'm doing my First Year Project at the moment and it's a web based resource / volunteer management database.
One of the things I put in my design was to have a way of creating a volunteer record and letting the user select which schools the volunteer can work in - obviously this would be easy if a volunteer worked in just one school (incidently this is for a christian schools work charity) but as I said it needs to be multiple schools - I've created the link entities needed to do this, but I'm really confused as to how I'd set up a sub form in dreamweaver - got the idea from Access - we did it in our db module.
Any ideas would be greatly appreciated

thanks


Stu Helm
---------
DWMX2004 / PHP / MySQL
Csoft.net Hosting

Replies

Replied 25 Apr 2005 15:55:52
25 Apr 2005 15:55:52 Matt Bailey replied:
Sounds like you need to find out about database 'normalisation'. Essentially this means setting up your database in a way that avoids as much reproduction of data as possible.

I first learnt about this from one of the Premium Content articles on this site (www.dmxzone.com/showDetail.asp?TypeId=28&NewsId=5831) - well worth the couple of dollars it costs!

Here's a really simple example:


TABLE 1 (Users)

UserID - 1
UserName - Bob
UserID - 2
UserName - Jim


TABLE 2 (Schools)

SchoolID - 1
SchoolName - St Georges Highschool
SchoolID - 2
SchoolName - Sunnyvale High


TABLE 3 (Data linking table)

ID - 1
UserID - 1
SchoolID - 1
ID - 2
UserID - 1
SchoolID - 2
ID - 3
UserID - 2
SchoolID - 1


And so on...

Basically you've got two tables containing your users and schools, linked by another table (by the various ID numbers, or 'Foreign Keys').

Does that make any sense, or have I just confused you?

___________________________________
* Sorry... how do you do that again?... *
Replied 25 Apr 2005 20:05:34
25 Apr 2005 20:05:34 Stu Helm replied:
Thanks for the reply
I know about normalisation, one of the things we covered in the Database module - and that's set up in the database - however what I'm trying to do is create a data entry form that allows the details of the volunteer to be entered and then (say as a table) multiple schools to be selected for that volunteer

Does that make sense, is it even possible with Dreamweaver?


Stu Helm
---------
DWMX2004 / PHP / MySQL
Csoft.net Hosting
Replied 25 Apr 2005 23:15:50
25 Apr 2005 23:15:50 Matt Bailey replied:
Ah... So if I've understood you right you want to enter data into multiple rows at once. I posted a bit of code recently for someone else that might help you (it's near the bottom of the page):

www.dmxzone.com/forum/topic.asp?TOPIC_ID=31454&FORUM_ID=2&CAT_ID=2&Topic_Title=List+box+and+Check+box&Forum_Title=Dreamweaver

Basically it involves multiple form choices (in this example with checkboxes), setting up the result as an array and then looping over the insert code however many times are needed. Have a look and if you're unsure of anything let me know and I'll do my best to explain (still fairly new to this PHP stuff myself though).

___________________________________
* Sorry... how do you do that again?... *

Edited by - matm00 on 25 Apr 2005 23:16:42

Reply to this topic