Tiny problem

Status
Not open for further replies.

Joseph Grogan

New Member
Hi everyone.. Ok I have a db set up that two tables in it

One called nt_posts the other nt_category

Inside nt_posts i have
  • post_id
  • post_name
  • post_content
  • category_id
and in nt_category i have
  • category_id
  • category_name
Now i have a form set up and I can select a category name to input into the category_id of the nt_posts table and it works fine as i checked it in phpmyadmin and it enters the info properly.

Now here is the problem. I have a page that outputs all the posts and on the side are category links. So when I click on a category it will only display ones with that category_id. It works when the category_id=1 but not for any other bnumber.

Here is the php code i am using to select results from seperate tables as i want to be able to say what category they selected

PHP:
$query = "SELECT * FROM nt_post, nt_category WHERE nt_post.category_id=$category_id = nt_category.category_id=$category_id";

It works fine if i only have it selecting from one table (the nt_posts table) but then i can display the name of the category.

Any one have any ideas
 

Forbairt

Teaching / Designing / Developing
quick look .. didn't read your post fully but ... this should work I think

Code:
$query = "
  SELECT
    *
  FROM 
    nt_post, 
    nt_category 
  WHERE 
    nt_post.category_id=$category_id AND
    nt_category.category_id = nt_post.category_id
";
 

Forbairt

Teaching / Designing / Developing
no problem ... I'm having a day of too many work emails and calls ... its doing my head in :D I want to get back to some coding :D
 

Forbairt

Teaching / Designing / Developing
thats one way of looking at it ... :)

Actually a good bit of support and proposals (I like to think they are decent ... thought the clients may disagree :D)
 
Status
Not open for further replies.
Top