charliepoo Posted August 21, 2010 Share Posted August 21, 2010 Yes I did just turn array into a verb I'm going to sound really noobish right now, but anyway I'm working with FanUpdate and I'm trying to display a list of the posts in a category by a link, so that on the navigation bar I don't have to keep adding every time a post gets added. This is what I have so far: <?php mysql_select_db("charioti_hive", $con); $result = mysql_query("SELECT * FROM blog_catjoin WHERE cat_id='8'"); while($row = mysql_fetch_array($result)) { echo "<a href=/activities.php?id=" . $row['entry_id'] . " class=n>"; } mysql_close($con); ?> So that loads obviously, all the entry_ids which are in category 8 and displays the link. This all works - what I'm wanting to do is query another table using these entry IDs so that I can get the entry names, so that instead of displaying "link" each time it displays the entry's actual name. Guessing it's fairly simple, but I've looked it up in my php book and I've googled it and can't find a tutorial that is simple enough for a dummy like me. Any help or even hints to where to go from here would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/211370-mysql-php-arraying/ Share on other sites More sharing options...
jcbones Posted August 21, 2010 Share Posted August 21, 2010 Give us the table names, and the table structures. You can do this with one query using a table JOIN. Quote Link to comment https://forums.phpfreaks.com/topic/211370-mysql-php-arraying/#findComment-1102116 Share on other sites More sharing options...
charliepoo Posted August 21, 2010 Author Share Posted August 21, 2010 blog_catjoin - contains entry_id and cat_id blog - entry_id, added, title, body, is_public, comments_on Entry_id and title being the ones I'm wanting to manipulate. Quote Link to comment https://forums.phpfreaks.com/topic/211370-mysql-php-arraying/#findComment-1102154 Share on other sites More sharing options...
jcbones Posted August 21, 2010 Share Posted August 21, 2010 Try: $query = "SELECT a.entry_id, b.title FROM blog_catjoin as a, blog as b WHERE (a.entry_id = b.entry_id) AND a.cat_id='8'"; $result = mysql_query($query) or die($query . ' <br /> ' . mysql_error()); while($row = mysql_fetch_array($result)) { echo "<a href=/activities.php?id=" . $row['entry_id'] . " class=n>" . $row['title'] . '</a><br />' . "\n"; } mysql_close($con); ?> And let us know how it goes... Quote Link to comment https://forums.phpfreaks.com/topic/211370-mysql-php-arraying/#findComment-1102158 Share on other sites More sharing options...
charliepoo Posted August 21, 2010 Author Share Posted August 21, 2010 Thankyou, that's exactly what I needed! It works perfectly (: Quote Link to comment https://forums.phpfreaks.com/topic/211370-mysql-php-arraying/#findComment-1102162 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.