我在另一个内部运行一个,但第二个只运行一次为什么以及如何解决它。我也尝试过,但只运行一次。
$sql = "SELECT DISTINCT season FROM search WHERE link = '$getid' Order by id asc";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
while ($list = mysql_fetch_assoc($result))
{
$season = $list['season'];
$sql = mysql_query("SELECT * FROM search WHERE link = '$getid' and season = '$season'");
$episodes = mysql_num_rows($sql);
echo '1st';
$sqls = "SELECT * FROM search WHERE link = '$getid' and season = '$season' Order by id asc";
$results = mysql_query($sqls, $conn) or trigger_error("SQL", E_USER_ERROR);
while ($lists = mysql_fetch_assoc($results))
{
$episode = $lists['episode'];
echo'2nd';
}
}
答案 0 :(得分:3)
您要覆盖变量,使用不同的变量:
$sql = "SELECT DISTINCT season FROM search WHERE link = '$getid' Order by id asc";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
while ($list = mysql_fetch_assoc($result))
{
$season = $list['season'];
$sql2 = mysql_query("SELECT * FROM search WHERE link = '$getid' and season = '$season'");
$episodes = mysql_num_rows($sql2);
echo '1st';
$sqls = "SELECT * FROM search WHERE link = '$getid' and season = '$season' Order by id asc";
$results2 = mysql_query($sqls, $conn) or trigger_error("SQL", E_USER_ERROR);
while ($lists2 = mysql_fetch_assoc($results2))
{
$episode = $list2['episode'];
echo'2nd';
}
}