Adding an integer at the end of an input's name to get a specific url
- by Gadgetster
I am trying to get a url where I can retrieve the selected values from.
For example, if I put a check mark on a and b then sumbit, I will get:
index.php?category=1&&category=2
I want to get this instead: index.php?category0=1&&category1=2
So that I can later get this specific value with $_GET['category0']
Is there a way to add a counter for the selected checkboxes and add 0,1,2,3.. at the end of the name of its input?
<form action="" method="get">
<!-- this will be a php loop instead of hardcored
which will retrieve data from the db -->
<label><input type="checkbox" name="category" value="1">a</label>
<label><input type="checkbox" name="category" value="2">b</label>
<label><input type="checkbox" name="category" value="3">c</label>
<label><input type="checkbox" name="category" value="4">d</label>
<label><input type="checkbox" name="category" value="5">e</label>
<input type="submit">
</form>