我有一個「無稽之談」的問題與PHP。第一循環應該從表中得到一定的記錄,並把它比作在第二個表中的所有記錄...嵌套while循環不工作?
所以我希望它打印41「第二」的每一個‘第一次’後的。由於第二個表中有41條記錄。但是,while循環第一次工作,並忽略第二個while循環。
結果我得到:
1st2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd2nd1st1st1st1st1st1st1st1st1st1st1st1st1st1st1st1st1st1st1st1st1st1st1st ...
while($row = mysql_fetch_array($select))
{
echo "1st";
while($row2 = mysql_fetch_array($select2))
{
echo "2nd";
$string = $row2["header"];
$find = $row["email"];
if(strstr($string, $find)) {
$email = $row["email"];
echo "found it";
} else {
//no email found
}
}
}
您是否嘗試過使用嵌套for循環而不是while循環?對於(在數據的每個項目){用於...} – lukeocom