有人可以指出错误吗?我在没有循环的情况下运行,代码工作正常但是for循环没有执行,也没有显示错误..
if(isset( $_POST['name'], $_POST['samplecount'], $_POST['decks']))
{
$name = $_POST['name'];
$sample = $_POST['samplecount'];
$decks = $_POST['decks'];
$rows = ($sample/$decks);
for ($i=0; $i<$decks; $i++){
for ($j=1; $j<=$rows; $j++) {
$stmt = $dbconnect -> prepare(" INSERT INTO decks (id, dnumber, vtext)
( SELECT :id, :dnumber,
(SELECT r.vtext FROM rsample r WHERE r.groupname = :groupname AND r.vtext
NOT IN (SELECT vtext FROM decks)
ORDER BY rand() LIMIT :rows)
)
");
$stmt -> bindValue(':id', $i);
$stmt -> bindValue(':dnumber', $j);
$stmt -> bindValue(':groupname',$name)
$stmt -> bindValue(':rows', $rows);
$stmt -> execute ();
}
}
}
在我的代码中,我使用name = "test"
值samplecount = 8
和decks = 2
。因此$rows
将是4
。
感谢。