I am trying to use for loop as a method to send in multiple data, however, the number that I want to loop is not the one I want to send in. For example, when i allocated 10001 - 10005, it only stores in the data 10001 - 10002. And everytime no matter how many different amount i allocate, it only stores in 2 data which is the first 2 number from the range i want to allocate, instead of the amount i required. I believe is the method of me looping got error. Please help.
@processallocate.php
See as Text
<?php
for ($cardfrom = $cardfrom; $cardfrom <= $cardto; $cardfrom++) {
if ($cardfrom) {
$mysqli = new mysqli(spf, dbuser, dbpw, db);
$stmt = $mysqli->prepare("INSERT INTO allocation
(cardfrom)
VALUES (?)");
$stmt->bind_param("s", $cardfrom);
$result = $stmt->execute();
if ($result == true && $stmt->affected_rows > 0) {
echo "<b>" . $check . "</b><br />";
}
else {
echo '<p>Taxi Voucher has already been allocated</p>';
break;
}
$stmt->close();
$mysqli->close();
}
else {
echo '<p>Error</p>';
echo '<p>Please <a href="allocation.php">Click Here</a> to resubmit</p>';
}
}
?>