umar000
Posts: 16
|
| Posted: 01/19/2011, 9:40 PM |
|
i have two database tables with one to many relation, i want to desgin record form which allow me to insert in one to many tables, i.e
one table is student name and other is subject
i want php form where i can insert one student name and multiple subject aginst him
how this form will be build? plz help me, its urgent?
_________________
Umar |
 |
 |
andrewi
Posts: 162
|
| Posted: 01/20/2011, 7:45 AM |
|
Take a look at the "Working with multiple selections" examples about half way down this page. http://examples.codecharge.com/
Especially "Updating Many-to-Many Relations via Two Listboxes" http://examples.codecharge.com/ExamplePack/ManyToManyLi...nyListboxes.php
This allows you to insert (or update) a master record and multiple related records at the same time. Change Employee to Student and Project to Subject and it sounds like your scenario. There's a link on the page giving notes on how to create it, and you can download the example pack so you can see the whole code.
|
 |
 |
Waspman
Posts: 948
|
| Posted: 01/21/2011, 8:04 AM |
|
Careful, I found out the hard way not use last record approach. I does say it's not good in the example. But if you don't have multiple users it should be OK.
_________________
http://www.waspmedia.co.uk |
 |
 |
andrewi
Posts: 162
|
| Posted: 01/21/2011, 10:35 AM |
|
Yes, that's not a very safe way of getting the just-inserted record's ID. But if you replace that with a more secure method - say by querying LAST_INSERT_ID() for the connection (the forum has several posts about using this) - then the rest of the example should be OK.
|
 |
 |
|