Ashoar Posted April 12, 2009 Share Posted April 12, 2009 Ok so this was posted originally a few days ago where i received a solution to the problem from Mark. Although this worked well i am in need of extending this to get more data, but withouth a certain JOIN element in the MYSQL query. What this code here does, is fetches all topics from a certain board. The topics are determined by the parentid='0', which means they are a thread and not a reply. What i now need to do is also get all replies for each board, which means i need to remove the parentid part of the query. I thought maybe i could add a second query to do this, but when i do so it just runs through the array and displays the same board over and over as well as the same topic count. Here is the code: $boards = mysql_query("SELECT f.forum_name, f.forum_desc, f.board, COUNT(p.post) AS threads, MAX(p.showtime) AS showtime, MAX(p.lastposter) AS lastposter FROM forums AS f LEFT JOIN post_reply AS p ON p.board=f.board AND p.parentid='0' GROUP BY f.forum_name, f.forum_desc, f.board ORDER BY f.forum_id asc") or die(mysql_error()); $boards2 = mysql_num_rows($boards); for($count = 1; $count <= $boards2; $count++) { $board = mysql_fetch_array($boards); So is there a way to change this around a bit so that i can get the replies, for each board as well as the posts? To get the replies it is the same but without parentid, but i cant take parentid out as it will then not show the posts. Quote Link to comment https://forums.phpfreaks.com/topic/153726-fetching-mysql-data-2/ Share on other sites More sharing options...
Ashoar Posted April 12, 2009 Author Share Posted April 12, 2009 Just knocking this back up to the first page. Quote Link to comment https://forums.phpfreaks.com/topic/153726-fetching-mysql-data-2/#findComment-807973 Share on other sites More sharing options...
Ashoar Posted April 13, 2009 Author Share Posted April 13, 2009 Back to first page. Quote Link to comment https://forums.phpfreaks.com/topic/153726-fetching-mysql-data-2/#findComment-808376 Share on other sites More sharing options...
Ashoar Posted April 14, 2009 Author Share Posted April 14, 2009 Back to first page. Quote Link to comment https://forums.phpfreaks.com/topic/153726-fetching-mysql-data-2/#findComment-809600 Share on other sites More sharing options...
fenway Posted April 15, 2009 Share Posted April 15, 2009 So is there a way to change this around a bit so that i can get the replies, for each board as well as the posts? To get the replies it is the same but without parentid, but i cant take parentid out as it will then not show the posts. I have no idea what this means. And that's quite enough bumping. Quote Link to comment https://forums.phpfreaks.com/topic/153726-fetching-mysql-data-2/#findComment-810589 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.