dontpanic
01-24-2004, 03:21 AM
I made the query, template and page code using existing, working elements in use elsewhere. My questions are these:
1. Why does this return only one result, when it should obviously return 10?
2. Why does it not return the correct results...the top article has over 6000 views.
The page in question (and there are two sets of this problem on it) is: http://www.mcseworld.com/forums/library.php
The query, template and page code were revised from that which drives this page: http://www.mcseworld.com/forums/lastthreads.php where they work quite nicely.
The SQL query:// Get Popular Articles
$populararticle = $DB_site->query("SELECT * FROM thread WHERE forumid IN (252,253,254,255,256,257,258,259,260,261,262,263,2 64) ORDER BY views DESC LIMIT 10");
while ($populararticles = $DB_site->fetch_array($populararticle))
{
eval('$library_populararticles = "' . fetch_template('library_populararticles') . '";');
}
// Get Popular ArticlesThe forumid numbers listed are the forums that house my Library articles...and of course, I would like 10 rows returned by the query from most popular (most view) down.
The template:<table border="0" cellpadding="2" width="100%" style="border-collapse: collapse" bordercolor="#111111">
<tr><span class="smallfont">
<td class="alt1Active" width="60%" align="left" valign="top"><span class="smallfont"><a href="showthread.php?$session[sessionurl]goto=lastpost&t=$populararticles[threadid]">$populararticles[title]</td>
<td class="alt1Active" width="20%" align="left" valign="top"><span class="smallfont"><a href="member.php?$session[sessionurl]find=lastposter&t=$populararticles[threadid]">$populararticles[lastposter]</a></b></td>
<td class="alt1Active" width="20%" align="left" valign="top"><span class="smallfont">$populararticles[views]</b></td>
</span>
</tr>
</table>The actual code on the page:<!-- popular articles -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tbody>
<tr>
<td class="thead" colspan="3">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_articles)"><img id="collapseimg_forumhome_articles" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_articles].gif" alt="" border="0" /></a>
Most Popular Articles Posted in the Library
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_articles" style="$vbcollapse[collapseobj_forumhome_articles]">
<tr><span class="smallfont">
<td class="alt1Active" width="60%" align="left" valign="top"><span class="smallfont"><b>Article</b></td>
<td class="alt1Active" width="20%" align="left" valign="top"><b>Author</b></td>
<td class="alt1Active" width="20%" align="left" valign="top"><b>Views</b></td>
</span>
</tr>
<tr>
<td class="alt1Active" colspan="3">$library_populararticles</td>
</tr>
</tbody>
</table>
<!-- popular articles -->Thanks in advance to anyone who can help me figure this one out.
1. Why does this return only one result, when it should obviously return 10?
2. Why does it not return the correct results...the top article has over 6000 views.
The page in question (and there are two sets of this problem on it) is: http://www.mcseworld.com/forums/library.php
The query, template and page code were revised from that which drives this page: http://www.mcseworld.com/forums/lastthreads.php where they work quite nicely.
The SQL query:// Get Popular Articles
$populararticle = $DB_site->query("SELECT * FROM thread WHERE forumid IN (252,253,254,255,256,257,258,259,260,261,262,263,2 64) ORDER BY views DESC LIMIT 10");
while ($populararticles = $DB_site->fetch_array($populararticle))
{
eval('$library_populararticles = "' . fetch_template('library_populararticles') . '";');
}
// Get Popular ArticlesThe forumid numbers listed are the forums that house my Library articles...and of course, I would like 10 rows returned by the query from most popular (most view) down.
The template:<table border="0" cellpadding="2" width="100%" style="border-collapse: collapse" bordercolor="#111111">
<tr><span class="smallfont">
<td class="alt1Active" width="60%" align="left" valign="top"><span class="smallfont"><a href="showthread.php?$session[sessionurl]goto=lastpost&t=$populararticles[threadid]">$populararticles[title]</td>
<td class="alt1Active" width="20%" align="left" valign="top"><span class="smallfont"><a href="member.php?$session[sessionurl]find=lastposter&t=$populararticles[threadid]">$populararticles[lastposter]</a></b></td>
<td class="alt1Active" width="20%" align="left" valign="top"><span class="smallfont">$populararticles[views]</b></td>
</span>
</tr>
</table>The actual code on the page:<!-- popular articles -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tbody>
<tr>
<td class="thead" colspan="3">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_articles)"><img id="collapseimg_forumhome_articles" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_articles].gif" alt="" border="0" /></a>
Most Popular Articles Posted in the Library
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_articles" style="$vbcollapse[collapseobj_forumhome_articles]">
<tr><span class="smallfont">
<td class="alt1Active" width="60%" align="left" valign="top"><span class="smallfont"><b>Article</b></td>
<td class="alt1Active" width="20%" align="left" valign="top"><b>Author</b></td>
<td class="alt1Active" width="20%" align="left" valign="top"><b>Views</b></td>
</span>
</tr>
<tr>
<td class="alt1Active" colspan="3">$library_populararticles</td>
</tr>
</tbody>
</table>
<!-- popular articles -->Thanks in advance to anyone who can help me figure this one out.