简体   繁体   English

如何使用一种形式将数据发送到mysql数据库中的不同表

[英]how to send data to different tables in mysql database using one form

Im creating a college management system . 我正在建立大学管理制度。 So depending on the department and level registered by the student to should go to the required table . 因此,根据学生注册的部门和级别,应转到所需的表。 I have 9 tables; 我有9张桌子; 3 business administration table for three levels ie 100level ,200level, 300level 3个业务管理表,分为三个级别,即100级,200级,300级

3 Pharmacy table for three levels ie 100level ,200level, 300level 3个药房表,分为三个级别,即100级,200级,300级

3 Computer science table for three levels ie 100level ,200level, 300level 3三个级别的计算机科学表,即100级,200级,300级

You should try something before posting question. 在发布问题之前,您应该先尝试一下。 You could probably try this logic: 您可能可以尝试以下逻辑:

If pharmacy is selected and particular level is selected then in your PHP script, 如果选择了药房并且选择了特定级别,则在PHP脚本中,

<?php
if(isset($_POST['pharmacy']) && $_POST['level']=='100'){
    $data = // Place your data here...
    $table_name = 'pharmacy_100';
}
else if(isset($_POST['pharmacy']) && $_POST['level']=='200'){
    $data = // Place your data here...
    $table_name = 'pharmacy_200';
}
else if(isset($_POST['pharmacy']) && $_POST['level']=='300'){
    $data = // Place your data here...
    $table_name = 'pharmacy_300';
}
// Same for all 3 branches...
?>

Now, you will have $data variable ready to store in database. 现在,您将可以将$data变量准备存储在数据库中。 By means of SQL connection you can add it in database. 通过SQL连接,您可以将其添加到数据库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel 将数据从一个表格保存到不同的数据库表 - Laravel save data from one form to different database tables 如何使用表单标签将数据发送到数据库? - How to send data to database using form tag? 使用php将数据从表单插入到mysql数据库的多个表中 - Inserting data from a form to multiple tables in a mysql database using php 如何从联接5个不同表的mysql数据库中检索数据 - How to retrieve data from mysql database joining 5 different tables 如何检索存储在MySQL数据库中不同表中的所有数据? - How to retrieve all the data stored in different tables in a MySQL database? 如何在Laravel中将一个表单数据更新到不同的表? - How to Update one form data to different tables in Laravel? 如何使用单个表单在2个不同的表中插入表单数据 - How To Insert Form Data In 2 different tables using single form 如何通过一个查询从3个不同的mysql表中获取数据 - How to get data from 3 different mysql tables with one query 如何将不同的表单数据发送到php文件以保存在数据库中 - how to send different form data to a php file for saving in database 如何使用锚标记将信息从一个页面发送到另一个页面,并从php中的数据库中获取数据 - how to send information form one page to another page using anchor tag and fetch data from database in php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM