Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,754 members, 7,809,892 topics. Date: Friday, 26 April 2024 at 04:42 PM

How To Insert Items Into Different Table - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / How To Insert Items Into Different Table (1408 Views)

PHP Code To Insert And Retrieve Images From Mysql Server / Mongoose/xampp: Using Php(on Mongoose) To Insert Data Into Mysql On Xampp / How To Insert Data Into An Online Mysql Database In Java (2) (3) (4)

(1) (Reply) (Go Down)

How To Insert Items Into Different Table by urchhm: 10:15pm On Jul 05, 2015
Please i need urgent help. I want a php code that can help me insert data into different tables in a database based on the item selected from a listbox. The application am creating will calculate school result. i have i form for adding name into the database. I want a situation where when a class is select from a listbox and the student's name is typed on the textbox,then the data will be submitted in the table based on the class selected. The database contains tables for each class. I also want a situation when a class is selected from listbox, the names of the students in that class will populate the second listbox called name.
Re: How To Insert Items Into Different Table by Craigston: 12:21am On Jul 06, 2015
It's doable. Have you attempted it yourself? I can't start designing the database and developing the application just to demonstrate an example. You can help us by describing the related databases and tables, and make an attempt at the program to handle the data.

1 Like

Re: How To Insert Items Into Different Table by Ebenstyles(m): 10:25am On Jul 07, 2015
You can use MySQL transaction in sending multiple queries, but one still need to see what you're trying to do. Can u give a sample?

1 Like

Re: How To Insert Items Into Different Table by urchhm: 3:12pm On Jul 07, 2015
I have tables in a database like Jss1, Jss2 to SS3. I want to use the same form to submit score into the different tables. The for has a listbox which contains Jss1, Jss2 to SS3 and second listbox which name. When Jss1 is selected, the second listbox will be populated with the names of people in that class. And the scores will submitted into Jss1 table in the database etc
Re: How To Insert Items Into Different Table by Nobody: 7:19pm On Jul 07, 2015
urchhm:
I have tables in a database like Jss1, Jss2 to SS3. I want to use the same form to submit score into the different tables. The for has a listbox which contains Jss1, Jss2 to SS3 and second listbox which name. When Jss1 is selected, the second listbox will be populated with the names of people in that class. And the scores will submitted into Jss1 table in the database etc

you dont need multiple tables for this. If youre using winforms for this (of which i hope u are), then u need only to create a field for 'class'. Then in the form, insert a combobox, and edit its items to jss1, jss2, etc.
Then u can invoke the combobox1_SelectionChangedCommitted() method;
then type in
urdatabindingsource.filter = "class = ' " +combobox1.Text+" ' "
NOTE: make sure ur ComboBox is binded to the database you created!!
that should solve ur problem.
Re: How To Insert Items Into Different Table by Nobody: 7:21pm On Jul 07, 2015
urchhm:
I have tables in a database like Jss1, Jss2 to SS3. I want to use the same form to submit score into the different tables. The for has a listbox which contains Jss1, Jss2 to SS3 and second listbox which name. When Jss1 is selected, the second listbox will be populated with the names of people in that class. And the scores will submitted into Jss1 table in the database etc
I laff in swahili, it is only one single table you need for this operation my friend! You are not yet equipped for this kind of task.
Re: How To Insert Items Into Different Table by timotew: 7:39pm On Jul 07, 2015
urchhm:
Please i need urgent help. I want a php code that can help me insert data into different tables in a database based on the item selected from a listbox. The application am creating will calculate school result. i have i form for adding name into the database. I want a situation where when a class is select from a listbox and the student's name is typed on the textbox,then the data will be submitted in the table based on the class selected. The database contains tables for each class. I also want a situation when a class is selected from listbox, the names of the students in that class will populate the second listbox called name.
This is ridiculous it like you are asking every programmer here to write you an essay on your topic.
To make it simpler please paste the code here, then everyone can see a suggest a solution.
Re: How To Insert Items Into Different Table by Nobody: 7:40pm On Jul 07, 2015
Most ridiculous indeed. When you make a post like this without writing any codes, well, i too will not reply with codes. . . .

1 Like

Re: How To Insert Items Into Different Table by Nobody: 6:49pm On Aug 24, 2016
[s]The poster above me should be jailed for 50 years[/s]
Re: How To Insert Items Into Different Table by guente02(m): 9:59pm On Aug 24, 2016
dhtml18:
[s]The poster above me should be jailed for 50 years[/s]
You meant 50++ years.
Re: How To Insert Items Into Different Table by Nobody: 10:40pm On Aug 24, 2016
Err, i did not say anything o
Re: How To Insert Items Into Different Table by FrankLampard: 11:53pm On Aug 25, 2016
urchhm:
I have tables in a database like Jss1, Jss2 to SS3. I want to use the same form to submit score into the different tables. The for has a listbox which contains Jss1, Jss2 to SS3 and second listbox which name. When Jss1 is selected, the second listbox will be populated with the names of people in that class. And the scores will submitted into Jss1 table in the database etc

Your task is very simple.

Just create a request that will host your listbox, when that listbox is selected you input a the value inside the selected listbox, or drop down list.

You can achieve this using if....elseif statement, or for better optimization, you can use a switch statement.

For example, you have table jss1, jss2...ss3

From your html code get your request object. Maybe using a <select></select> statement
Then in your php write your switch or if....elseif statement, like thus

If($_POST['fromYourHTML']= "jss1'){
//insert into jss1 table.
}elseif($_POST['fromYourHTML'] == 'jss2'){
//WWrite your SQL query to insert in table jss2
}

And so on, if I understand you very well, this should solve your challenge.

Use a switch statement for better optimization, in web development every seconds counts.

Feel free to ask mor questions. Thank you.

(1) (Reply)

ICT Training Manual For Primary School And Secondary Schools / Frontend Devloper/designer Needed / Get A Beautiful Website For Just ₦‎1,000,000

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 23
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.