I have a problem I cant get my head around. I have numerous Tables in one database. Each table is identical as its for courses. I have a login system where a student logs in and needs to tick a form to say they are attending an exam. The problem is that their could be multiple courses going on at once so I will never know what table is being used as each table is unique to that course I will only know for definite the database which is call Loginregister. I need it to update the the table that they are attending. I have tried information schema but I am aware that this is a read only. I'm sure there is a much more easier way to do this.
$hostname="localhost";
$username="root";
$password="root";
$dbname="loginregister";
//Connect to the database
$connection = mysqli_connect($hostname,$username,$password,$dbname);
if ($connection->connect_error) {
die("Connection failed: ". $connection->connect_error);
echo 'Connection problem <br>'.$connection->connect_error;
}
//Below is coming from the form
if(!empty($ExamAttending))
{
$sql1 = "UPDATE INFORMATION_SCHEMA.COLUMNS
SET ExamDates = '$ExamAttending' WHERE Username= '$StudentId'";
echo 'Thank you your request has been saved :'.$ExamAttending."<br>".$StudentId.'<br>';
}if ($connection->query($sql1) === TRUE) {
echo "Record updated successfully: ".$Module_0;
} else {
echo "Error updating record: " . $connection->error;
}