我正在尝试使用for循环作为发送多个数据的方法,但是,我想要循环的数字不是我要发送的数字。例如,当我分配10001 - 10005时,它只存储在数据10001-10002中。并且每次无论我分配多少不同的金额,它只存储在2个数据中,这是我想要分配的范围中的前2个数字,而不是我需要的数量。我相信是循环得到错误的方法。请帮忙。
@ processallocate.php
见文字
<?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>';
}
}
?>
答案 0 :(得分:1)
我认为问题在于你的IF..ELSE条件。您正在使用import { eventChannel } from 'redux-saga';
import { cancelled, take } from 'redux-saga/effects';
// first create your eventChannel
const authEventsChannel = eventChannel( emit => {
const unsubscribe = firebaseAuth().onAuthStateChanged( user => {
emit({ user });
});
// return a function that can be used to unregister listeners when the saga is cancelled
return unsubscribe;
});
// then monitor those events in your saga
try {
while (true) {
const { user } = yield take (authEventsChannel);
// handle auth state
}
} finally {
// unregister listener if the saga was cancelled
if (yield cancelled()) authEventsChannel.close();
}
作为迭代计数器。
然后在循环内部,您正在检查$cardfrom
是否评估任何&#34; truthy&#34; value(布尔值为TRUE,或非空,非NULL值或非零数字)
只有它是真的,你正在做mysql插入部分!
因此,请检查代码中的逻辑,看看它是否符合您的期望!
希望有所帮助