Attaching a category to a news item

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Aaron
Forum Commoner
Posts: 82
Joined: Sun May 12, 2002 2:51 pm

Attaching a category to a news item

Post by Aaron »

Hi Ive wrote 90% of my news system, I was wondering how to finish it off perfect.

At the moment posting news prompts you to fill in what category you would like the news to be under. From there what you specified is put into a field in the news row.

However, I plan to make a drop down menu that will attach an id to the news in the 'cat' field.

So I have a new table for categories, with certain details on the diffrent categories, and wondered what the query would be to call up the category from the number specified in the news table...i think...


Code: Select all

{$query = mysql_query("SELECT * FROM {$prefix}_news ORDER BY id DESC LIMIT 9");
while($result = mysql_fetch_array($query))

{$query2 = mysql_query("SELECT * FROM {$prefix}_category WHERE id = $resultїcat]");
while($result2 = mysql_fetch_array($query2))
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Code: Select all

<?php
$query2 = mysql_query("SELECT * FROM $prefix_category WHERE id = {$resultї'cat']}"); 
?>
Post Reply