Jump to content

MYSQL & php arraying?


charliepoo

Recommended Posts

Yes I did just turn array into a verb :P

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.

Link to comment
https://forums.phpfreaks.com/topic/211370-mysql-php-arraying/
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/211370-mysql-php-arraying/#findComment-1102158
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.