/    Sign up×
Community /Pin to ProfileBookmark

accessing part of another query

I have a articles system, and I want to make it display the section that the article that your viewing is in. The articles are stored in different tables from the sections, but in the articles table, it has a number for the section that it is in, and in the section table it has id which is the number thats also found in each article table row, and then it has the actual name. I know that I would have to get the number from the article-not a problem- for the section that its in, then, I need to access the sections table, and then have it print out the name that goes with the ID of the section. Now then, I have altered my query into this

[code]SELECT section,title,thearticle FROM cmsarticles WHERE ID = ‘.$_GET[‘id’][/code]

which will bring the section number out along with the rest of the article, but now, I need to write a query which can access this first query in some way, and allow it to match up the section number with the section name, and I dont know how I would go about this. Please help. Thanks, ~Travis

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@Heavy_MetalauthorAug 07.2006 — ok, is it that noone can help or that im being ignored here or what?
Copy linkTweet thisAlerts:
@Heavy_MetalauthorAug 07.2006 — Ok, I needed this done, so I went ahead with a temporary solution, which is this [code=php]<?
$sections = array(1 => 'Announcements');
echo "<b>Posted In: </b>".$sections[$row['section']];
?>[/code]
. And I would just use this, But as This is going inside a CMS, I REALLY need it to be automated so they dont have to update the array, But this will work until someone can help me.
Copy linkTweet thisAlerts:
@aussie_girlAug 08.2006 — I'm a little confused but..if you need to display certain fieldnames from multi tables, you need to have the tables in your FROM clause..cmsarticles, sections, etc

then if you have set them uo properly you should have a relationship between then tables, then you can do a join to connect them.
<i>
</i>SELECT section_name, articles, title
FROM section, cmsarticles
WHERE section.section_id = cmsarticles.section_id
AND &lt;search condition&gt;
Copy linkTweet thisAlerts:
@Heavy_MetalauthorAug 08.2006 — I could hug you, honestly, I could.
×

Success!

Help @Heavy_Metal spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...