Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website Design Forum


You are currently viewing our Website Design Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Listing all articles in a category (PHP)
Old 12-11-2006, 04:16 AM Listing all articles in a category (PHP)
Junior Talker

Posts: 3
Trades: 0
Table Structure:

Table
article
articlecategory
author
category

The category table lists the main categories while the articlecategory table is a join that lists the

category id and the article id.

On my main page I have all articles listed. However, I would like other pages to contain only stories

from category x, y etc.

I run the query:

Code:
$query = 'SELECT * FROM articlecategory WHERE categoryid=3';
but it returns nothing.
VBrandon is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-11-2006, 09:55 AM
Ultra Talker

Posts: 407
Trades: 1
You're not running a query there. You would need to use the following:

Code:
<?php
//...

$query = mysql_query("SELECT * FROM `articlecategory` WHERE `categoryid` = 3") or die(mysql_error());

if (mysql_num_rows($query) === 0) {
	// You have no categories here. Add some error code.
} else {
	while ($article = mysql_fetch_assoc($query)) {
		// This will loop for each article
		echo "{$article['name']}<br />";
	}
}

//...
?>
__________________
[
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
]
Lucas3677 is offline
Reply With Quote
View Public Profile Visit Lucas3677's homepage!
 
Reply     « Reply to Listing all articles in a category (PHP)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15124 seconds with 12 queries