因为$i = 0
并不总是被执行。仅当帐户不存在时才执行。然后创建帐户,因此在下一次通过时$i
不会重置为0
. 您还需要代码周围的上下文。
仅此行为的简化视图:
for($i = 0; $i < $numAccounts; $i++) {
$accountExistsQ = mysql_query("SELECT id FROM networkBlocks WHERE accountAddress = '".$transactions[$i]["txid"]."' ORDER BY blockNumber DESC LIMIT 0,1")or die(mysql_error());
$accountExists = mysql_num_rows($accountExistsQ);
if(!$accountExists) {
mysql_query("INSERT INTO `networkBlocks` (`blockNumber`, `timestamp`, `accountAddress`, `confirms`, `difficulty`) ".
"VALUES ('$assoc_block', '$assoc_timestamp', '" .$transactions[$i]["txid"]. "', '" .$transactions[$i]["confirmations"]. "', '$difficulty')");
$i=0;
}
}
}