dimanche 1 mars 2015

Form with dynamic content to insert multiple rows into MySQL database

I've been working on this for a few days now and have found posts that answer different parts of my problem, but not one yet that answers all of them and I have found a way to put it all together.


I am working on page that customers will order t-shirts from. I've simplified the form below, but essentially the table will pull data from one database table "shirts" for each display it on the form. Customers can specify how many of each size they would like to order. The table will repeat for each shirt depending on how many are in the database table at the time.



<form action="submit.php" method="post">
<input type="hidden" name="shirtID[]" value="<?php echo $row_shirts['shirtID'];?>" />

<label>Color</label>
<input type="text" name="color[]" />

<label>Small</label>
<input type="int" name="small[]" />

<label>Medium</label>
<input type="int" name="med[]" />

<label>Large</label>
<input type="int" name="large[]" />

<label>X-Large</label>
<input type="int" name="xl[]" />

<input name="Submit" type="submit" />
</form>`


I need to figure out how to submit multiple rows into another database table "orders" from this form. Any shirt that a customer is ordering should submit a different record for each size with the quantity and other info of the shirt associated with it.


If possible I would like to give them the opportunity to review and confirm the order before submiting it but right now I'm just focused on submitting the rows where a customer has entered a quantity to order.


Thanks in advance! This has been driving me crazy!


Aucun commentaire:

Enregistrer un commentaire