Populate table from mysql database through php -
residentcontroller table user table
i have database consists of 3 tables.
1.user:
-4 columns (userid [primary key], name, emailid, password)
2.residentcontroller:
-3 columns (userid [foreign], departmentid [foreign], checkdefault checkdefault set 1.)
3.department
-6 columns: (departmentid [primarykey], departmentname, departmentdesc, departmentlink, checkdefault, departmentcategory)
here sequence follows when user registers android application. following php script called. add record of user database. after insertion of data in user table, want "departmentnames" department table , insert residentcontroller. in end, after particular user registers, residentcontroller must have these values populated residentcontroller table.
userid departmentid checkdefault
1 1 1
1 2 1
1 3 1
1 4 1
1 5 1
<?php require "init.php"; $fullname = "fahman khan";//$_post["user"]; $emailid = "fxk120@hotmail.com";//$_post["user_name"]; $userpass = "windows";//$_post["user_pass"]; $sql_query = "insert user values (null,'$fullname','$emailid','$userpass')"; if(mysqli_query($connection, $sql_query)) { echo "<h2> data insertion success</h2>"; //get user id of the registered user $sql_querytwo = "select userid user emailid='".$emailid."'"; //store result of query in variable $result= mysqli_query($connection,$sql_querytwo); $row = mysqli_fetch_array($result); //retrive user id $data = $row[0]; //insert default departments residentcontroller //*********************************need on portion of script***** } else { //echo "data insertion error".mysqli_error($connection); } ?>
my question in current php script, don't know how can insert departmentid residentcontroller table. departmentid foreign key , in current department table there 5 departments. need writing part in php can insert in values residentcontroller table. of now, current php script adds new user, need inserting values residentcontroller table.
Comments
Post a Comment