So I'm just getting data from ajax POST to php api and trying to save that in the db. My table has a_id, a_owner, a_material, a_size, a_product. The needed data gets passed into the api correctly but I can't get it to save.
this is my sql statement. Also I'm not so sure i'm getting the $owner variable right. Thanks guys
$owner = "SELECT 'u_id' FROM 'user' WHERE 'u_email' = $data['email']";
$sth = $dbh -> prepare("INSERT INTO object (a_id, a_owner, a_material, a_size, a_product) SELECT MAX(a_id)+1, :owner, :material, :size, :product FROM object");
$sth->bindParam(':owner', $owner, PDO::PARAM_INT);
$sth->bindParam(':material', $data["material"], PDO::PARAM_INT);
$sth->bindParam(':size', $data['size'], PDO::PARAM_INT);
$sth->bindParam(':product', $data['product'], PDO::PARAM_INT);
$sth->execute();
Update
So I guess where I'm stuck on is getting 'owner' info.
So to clarify, owner belongs in object table and it value is the same as user id in the User table. User table also has an email column. So how do reference the email to get to user id and save it into owner in my object table?