hello, i can get the result on phpmyadmin by doing: SELECT topic, COUNT( * ) AS usercount FROM `file` GROUP BY topic HAVING usercount >1 PHP: how can i addapt this to my current query? $query = "SELECT COUNT(*) as num FROM file "; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* my codes continues.................*/ /* Get data. */ $sql = "SELECT * FROM file ORDER BY topic DESC LIMIT $start, $limit"; $result = mysql_query($sql); PHP: thanks alot.
Hi, I'm not sure about your desired result-set but you can try the following $sql = "SELECT * FROM `file` NATURAL JOIN (SELECT topic, COUNT( * ) AS usercount FROM `file` GROUP BY topic HAVING usercount >1) A ORDER BY A.topic DESC LIMIT {$start}, {$limit}"; PHP: Regards
thanks for replie. here is my code: $query = "SELECT COUNT(*) as num FROM file "; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* my codes continues.................*/ $sql = "SELECT * FROM file ORDER BY topic DESC LIMIT $start, $limit"; /* Get data. */ $result = mysql_query($sql); PHP: I want to show duplicated rows according to topic field. How can i do it on my code? Thaks alot.
i think your problems is shut out after using this code if not reply me right error $query = "SELECT COUNT(*) as num FROM file "; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num];