Im really new to php and need some help with coding. I have a mysql database with a table 'users' that contains 4 fields.
'room', 'first name', 'last name', 'weight' is there a way i can create a new record for each person everytime they are weighed? and be recalled by date at a later time?
any help greatfully received!
First you have to connect to your database using PDO Object...
$myPDO = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8", $user, $pass");
Next you have to create your create query, something like :
$query = "INSERT INTO my-table (room, first_name, last_name) VALUES (:room, :firstName, :lastName);
You have next to create a statement :
$statement = $myPDO->prepare($query);
Then bind your datas (becoming from a form, or csv file, ...) in order to execute the full query, something as :
$myDatas = [":room" => 102, ":firstName" => "You", ":lastName" => "Your Name"];
Finally :
$statement->execute($myDatas);
You can execute this in a try catch structure to intercept errors and fallback with a log, or whatever you want.