Hello & good afternoon,
I am developing an online product returns form which depending on the number of products the customer wants to return asks for the serial number of each one then i want to store each serial number in a MYSql database.
I just want to make sure i am creating the relevant number of columns the most efficient way & my code is as follows: -
if (isset($_POST['system_checkbox']))
{
for ($i = 1; $i <= $qty; $i++)
{
mysqli_query($db, "ALTER TABLE credit_table ADD Serial_Number_$i VARCHAR(255)");
}
}
As you can see i am just using a basic for loop so each column is creating columns Serial_Number_1, Serial_Number_2, etc with $qty being the number of products being returned.
I also want to write the value of each serial number field from the form into the relevant columns which is where I become stuck.
Any advice would be appreciated.
Thanks in advance. Lee.