Jump to content

Recommended Posts

I think you need to create a PHP script, return the results to an array using mysql_fetch_* and then loop through those results...

 

 

include "db.connection.php";

$query  = "SELECT * FROM bhl_contents INNER JOIN bhl_comments ON bhl_contents.artid = bhl_comments.artid ORDER BY COUNT(bhl_comments.artid) DESC LIMIT 10";
$result = mysql_query($query)or trigger_error("ERROR: " . mysql_error(), E_USER_ERROR);

   while ($row = mysql_fetch_row($result)) :
      echo '<pre>' . print_r($row, true) . '</pre>';
   endwhile;

 

:confused:

Ya, I have my php code and I tried it also

 

$CheckArtisList = $SiteDatabase->dbqueries("SELECT * FROM bhl_contents INNER JOIN bhl_comments ON bhl_contents.artid = bhl_comments.artid ORDER BY COUNT(bhl_comments.artid) DESC LIMIT 10");

		if(!$SiteDatabase->sql_numrows($CheckArtisList) == 1) {
			return false;
		}

		if (isset($_GET['Artid'])) {

		$Artid = intval($_GET['Artid']);

		$ArtiList = $SiteDatabase->dbqueries("SELECT `artid`, `subject`, `body`, `uid`, `username`, `curtime` FROM 
		" . ArticleSystem::BHL_DB_PREFIX . "" . ArticleSystem::BHL_CONT_MGM . " WHERE artid='".$Artid."'");

		}
		echo '<div class="lastarti">
				<div class="nav3">
					Last Articles
				</div>';
		while($row = $SiteDatabase->sql_fetchrow($CheckArtisList))
		{
		$Artid = intval($row['artid']);
		$Sub = $row['subject'];
		$Bod = $row['body'];
		$uid = $row['uid'];

		echo '<ul>
				<li><a href="' . $_SERVER['PHP_SELF'] .'?action=viewarti&artid='.$Artid.'">'.$Sub.'</a> By: <a href="'.$_SERVER['PHP_SELF'].'?action=ubrief&uid='.$uid.'">'.$row['username'].'</a></li>
			</ul>';
		}
		echo '</div>';

I'd say it has more to do with the fact, that a query with aggregate function ( COUNT() ) and no GROUP BY clause will always return but one row

 

SELECT 
  * 
FROM 
  bhl_contents 
CROSS JOIN (
  SELECT 
    artid
    COUNT(*) AS cnt
  FROM
    bhl_comments
  GROUP BY
     artid
) AS sq
USING (artid)
ORDER BY sq.cnt DESC
LIMIT 10

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.