i have large form in need to store data in. problem have form isn't static , can become larger, example user have 1++ addresses.
the current table consists of id,form_id,value , field columns. can add value form, how create unique identifier know field situated too.
$surname = isset($_post['surname'][0]) ? $_post['surname'][0] : ''; $address1 = isset($_post['address1'][0]) ? $_post['address1'][0] : ''; $address2 = isset($_post['address2'][0]) ? $_post['address2'][0] : ''; $address3 = isset($_post['address3'][0]) ? $_post['address3'][0] : '';
then push these array.
foreach ($applicant $value) { //statement insert data $stmt = $pdo->prepare("insert applicant1(form_id,value)values(?,?)"); $stmt->bindparam(1, $formid); $stmt->bindparam(2, $value); $stmt->execute(); }
how can name of field came or there different approach?
you should create database 2 tables, submission id submitted data information needed row. table should have pk primary key auto incremental. next table should designed gonna have multiple submissions of data may want collect. should have fk foreign key primary key of first table linking original submission. if using ajax , wanted in real-time upon new address return pk of row second table submitted , put in custom xml attribute element. data-fk grab fk if need else in real-time without reloading page.
Comments
Post a Comment