I have a variable generated by $_POST
called $quantity
,
What would be the correct way to run a loop based on the value of this variable?
I have a variable generated by $_POST
called $quantity
,
What would be the correct way to run a loop based on the value of this variable?
Well, assuming that $quantity
is numerical, you can do this:
for ($c = 0; $c < $quantity; $c++) {
//do whatever
}
You can do a for loop (I'm assuming you want to run some code $quantity number of times)
for ($i = 0; $i < $quantity; $i++) {
//
}
Just make sure to sanitize your POST data