CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 how to make php form for one to many relationship

Print topic Send  topic

Author Message
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
View profile  Send private message
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.
View profile  Send private message
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
View profile  Send private message
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.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.