I am creating a grade system, and I need some help.
I am creating a registration form, I've managed to insert the user details in the 'users' table, but I also want to insert the user ID and username in to a group table.
For example:
$sql = ("INSERT INTO `users`(`username`, `password`, `email`, `group`, `ip`, `signup`, `lastlogin`) VALUES ('$username','$email','$password','$group','$ip',now(),now())");
$query = mysqli_query($db_conx, $sql);
$uid = mysqli_insert_id($db_conx);
// Establish their row in the group table
$sql = ("INSERT INTO '.$group.'(id, username) VALUES ('$uid','$username')");
$query = mysqli_query($db_conx, $sql);
exit();
I'm not sure how I can put a dynamic variable ($group) as the table name and then insert the data in the correct group tables.
If anyone has a suggestion or now how to achieve this, any feedback would be greatly appreciated.