根据我在StackOverflow上给出的建议,我尝试了下面的查询,但没有奏效。我试图让数据库中的“地盘”,25最近添加值的列表,无论他们是在什么表下面的代码提供以下错误:Double While while not working
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in domain.php on line 82
线82 while ($rowa = mysql_fetch_array($indexa))
任何想法为什么它不工作?
echo "<table class=\"samples\">";
$index = mysql_query("select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='sitefeather'");
while ($row = mysql_fetch_array($index))
{
$indexa = mysql_query("select site FROM index order by createdatetime desc limit 25");
while ($rowa = mysql_fetch_array($indexa))
{
echo '<tr><td><a href="sitelookup3.php?entry='.urlencode($rowa['site']).'&searching=yes&search=search">'.$rowa['site'].'</a></td></tr>';
}
}
echo "</table>";
我收到一个错误,当我执行“select site FROM index order by createdatetime desc limit 25”时,它说表格索引一定不能用这种方式写。我想知道你为什么要运行与外部查询无关的内部查询。 – 2009-10-31 06:14:36
你会得到这个错误,因为index是mysql中的一个保留字,所以如果你打算将它用作表名,它必须被转义(在你的情况下,mysql正试图将它解释为它是一个真实的关键词)。 – shylent 2009-10-31 06:25:55
供参考:你使用的是一个* nested * while循环。我还建议你阅读代码缩进。 – Artelius 2009-10-31 06:38:46