Database and form concept

I am looking for a solution how to best create 18 forms from the initial form.

Concept for example:
I have a form - table_00 in which I enter all important and mandatory information. approx. 10 fields

After creating the page 00 - I need to create 18 pages. table_01 to table_18 and copy certain data from table_00 in them. The number of data is different for each page.
The two fields are identical in all tables. id and another_id.

I have everything already done and everything from my office works all without error.
But by the user does not work. Occasionally records are doubled. Empty records appear and this completely destroys the complete concept.
Because the id from the individual tables does not match anymore all inputs are mixed and useless.

My id is set to automatic increase in all tables.

I can not figure out where the error is and what goes wrong.
But I can not combine all the tables into one table and one form, because then it’s over 450 fields and it’s impossible to work with Scriptcase slowly and the database is slow.

I ask for some idea how to set up the concept and prevent these errors.

Thanks in advance

Use a tool like sqlyog to verify both databases against each other. If the application works well locally but not deployed then there must be some mismatch between the database structure in development and production. Probabely on the autoinc fields (missing) or foreign keys etc.

Maybe I did not explain it well.
The application is installed on a hosted server and the database is also on this server
1- I access from home and input data - everything is OK
2- One user tested the application before use and accessed from home. - everything is OK
3- Users who access the app from the business location, however, fail to make a mistake.
So in all three cases it is an identical database.

But not always. As if the error occurred randomly. What day is even all day OK, the second day there is an error.

The input scenario is as follows:
User enters 4 fields. Then the date field appears and in this field I have AjaxEvent to save the data:

sc_ajax_javascript (‘nm_atualiza’, array (“incluir”));

For this, there are two optional fields that are sometimes entered or not.

Then I have a php SAVE button to create all 18 forms with this code:

sc_commit_trans (); // save the changes (inserts the data)
izpolni_kpk_01 ();
izpolni_kpk_02 ();
izpolni_kpk_03 ();
izpolni_kpk_04 ();
izpolni_kpk_05 ();
izpolni_kpk_06 ();
izpolni_kpk_07 ();
izpolni_kpk_08 ();
izpolni_kpk_09 ();
izpolni_kpk_10 ();
izpolni_kpk_11 ();
izpolni_kpk_12 ();
izpolni_kpk_13 ();
izpolni_kpk_14 ();
izpolni_kpk_15 ();
izpolni_kpk_16 ();
izpolni_kpk_17 ();
izpolni_kpk_18 ();

sc_ajax_javascript (‘nm_atualiza’, array (“alterar”));

sc_redir (kpk_form_01.php, id = {id}, “_self”);

To switch to another page, I use a button with the following code:

$l_link = “…/kpk_form_02/kpk_form_02.php? id =”. {id};
{page_02} = “<a href=”.$l_link. "onclick = " nm_atualiza (‘alterar’); “> <img src = ‘…/_ lib/img/grp__NM__ico__NM__stran_02_green.png’/></a>”;

Although I do not know here exactly why I did this, I saved the data again, but if I sum up all the data I saved 3x.

Creation code. copying the data ( izpolni_kpk_04 (); ) into other tables is as follows:

/ * Complete the patient and his information on page 04 * /

$id_pacienta = {id_pacienta};
$datum_razgovora4 = {datum_razgovora};

/** * Check for an existing record */
// SQL statement parameters
$check_table = ‘kila_pot_04’; // Table name
$check_where = “id = ‘{id}’”; // Where clause
// Check for record
$check_sql = ‘SELECT *’
. ’ FROM ’ . $check_table
. ’ WHERE ’ . $check_where;
sc_select(dataset, $check_sql);

if (false == {dataset})
{
// Error while accessing database
}
elseif ({dataset}->EOF)
{

    // START No record found

/*** Insert a record on another table */
// SQL statement parameters
$insert_table = ‘kila_pot_04’; // Table name
$insert_fields = array( // Field list, add as many as needed

'id_pacienta' =&gt; "'$id_pacienta'",
'datum_razgovora4' =&gt; "'$datum_razgovora4'",    

);
// Insert record
$insert_sql = ‘INSERT INTO ’ . $insert_table
. ’ (’ . implode(’, ‘, array_keys($insert_fields)) . ‘)’
. ’ VALUES (’ . implode(’, ', array_values($insert_fields)) . ‘)’;
sc_exec_sql($insert_sql);
// END No record found
}
else
{
// START Record found
/*** Start Update a record on another table */
// SQL statement parameters
$update_table = ‘kila_pot_04’; // Table name
$update_where = “id = ‘{id}’”; // Where clause
$update_fields = array( // Field list, add as many as needed

// “id_pacienta = ‘$id_pacienta’”,
“datum_razgovora4 = ‘$datum_razgovora4’”,

);
// Update record
$update_sql = ‘UPDATE ’ . $update_table
. ’ SET ’ . implode(’, ', $update_fields)
. ’ WHERE ’ . $update_where;
sc_exec_sql($update_sql);
/*** End Update a record on another table */
// END Record found
}
// ***********************************************************************************************************************************************************************************

I have set the id for all tables on auto_increment.

Could it be a better idea to have only a table_00 auto_increment, and all others would be set to Auto Increment (manual), but I’m not sure how it works at all.

Any idea or advice what am I doing wrong?