[eluser]Unknown[/eluser]
Hi.
I have general page that contain 10 posts for each post can be 0 or many categories.
How I can show categories for each post?
Here my tables
Code:
CREATE TABLE IF NOT EXISTS `articles` (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
descr VARCHAR(255) NOT NULL,
alt_title VARCHAR(255) NOT NULL,
short_story TEXT NOT NULL,
full_story TEXT NOT NULL,
`date` DATETIME NOT NULL,
category varchar NOT NULL,
PRIMARY KEY (id),
FULLTEXT INDEX index_search (short_story, full_story),
INDEX index_title (title)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `categories` (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
category VARCHAR(255) NOT NULL,
alt_category VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
I want show 10 posts on page.
First I get 10 entries from table `articles`.
In artciles entry category can have '1|2' - that id's table categories.
Can you show me example function that can get all categories for each post.
I don't want use foreach for every post. Couse I think it very slow way.