Currently I’m working on a textbook ordering html form with PHP
User shown a list of textbook and theres a Quantity dropdown menu for each textbook (they can select to order 1 quantity or 2,3 or 4)
Each textbook have a unqiue textbookId number.
How can I create a html form which can determine which textbook they order and the quantity they order?
I usually solve this kind of problem by creating multiple html form (each form contain hidden field of textbookId) but the problem is that’s there will be multiple submit button.
But I only one submit button for the whole textbook list.
Can someone please help me 🙂 thanks so much in advance
If possible can you show me how to process the data in php as well.
Cheers
Here is my current html form code:
<div class="tables">
<form action="process-order" id="login-form" method="get" name="login-form"></form>
<table class="orders">
<tr>
<th>textbookId</th>
<th>Subject</th>
<th>Title</th>
<th>Price</th>
<th>Quantity</th>
</tr>
<tr>
<td>1</td>
<td>English</td>
<td>English ABC</td>
<td>33.00</td>
<td>
<div align="center">
<select name="mydropdown">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</div>
</td>
</tr>
<tr>
<td>2</td>
<td>Math</td>
<td>Math SignPost</td>
<td>122.00</td>
<td>
<div align="center">
<select name="mydropdown">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</div>
</td>
</tr>
</table>
<input type="submit" name="submit" id="submit" value="Next">
</form>
</div>
One possibility is to encode the book ID into the submitted form element e.g.
<select name="book_1">for the book 1.
PHP processes the books as follows: