Andy11548 Posted February 5, 2012 Share Posted February 5, 2012 I've tried joining querys, but I have no bloody clue what I'm doing lol. I'm using 2 querys, one to show the news, and one to pull the username from the id. If anyone could help, it'd be great. <?php include './includes/mysql/connect.php'; ?> <!DOCTYPE HTML> <head> <meta http-equiv="content-type" content="text/html" /> <meta name="author" content="Andy" /> <link href="./includes/css/css.css" rel="stylesheet" type="text/css" /> <title>Project Desination</title> </head> <body> <div id="wrapper"> <div id="header"> <div id="logo"></div> <div id="navMenu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="./forums/">Forums</a></li> </ul> </div> </div> <div id="contentHolder"> <div id="content"> <?php $query = mysql_query(" SELECT t1.post_id as PostID t1.poster_id as User t1.forum_id as Forum t1.post_subject as Title t1.post_text as Content (SELECT COUNT(*) FROM `phpbb_posts` as t2 WHERE t2.forum_id = '8') as NewsCount FROM phpbb_posts as t1 INNER JOIN phpbb_users as t2 ON t2.user_id = t1.poster_id ORDER BY t1.post_id DESC "); if(mysql_num_rows($query) != 0) { while($newsF = mysql_fetch_assoc($query)) { echo '<div id="title">'.$newsF['post_subject'].'</div>'; echo '<div id="text">'.$newsF['post_text'].'</div>'; echo '<div id="author"></div><br /><br />'; } } else { echo 'There is no news to be displayed.'; } ?> </div> <div id="recent">Testing</div> </div> <div class="clearFloat"></div> <div id="push"></div> </div> <div id="footer"> <span class="middle"></span> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
fenway Posted February 5, 2012 Share Posted February 5, 2012 That looks like a join -- what doesn't work? Quote Link to comment Share on other sites More sharing options...
digibucc Posted February 5, 2012 Share Posted February 5, 2012 i've never seen a query laid out like that, i assume for readability - is there any detriment to that? with some more complicated queries i might like to try that. Quote Link to comment Share on other sites More sharing options...
kickstart Posted February 6, 2012 Share Posted February 6, 2012 Hi Only thing I can spot wrong is that you have given alias' to some of the columns brought back by the SQL but then referred to the column names rather than the alias names when outputting them (eg you have used $newsF['post_subject'] rather than $newsF['Title']) All the best Keith Quote Link to comment 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.