I'm not sure how to word this in my title so I'll try and explain the best I can here.
I want to create a news page for my website, having around 8 articles per page, which would be one update via SQL. But I wondered if there was a way to select a particular article based on it's theme using PHP later on. What I would have are 2 tables:
Articles: ID | Article 1 | Article 2 | Article 3 | etc
Themes: ID | Theme 1 | Theme 2 | Theme 3 | etc
So a basic post would look like:
Articles: 1 | Text for article 1 | Text for article 2 | Text for article 3 | etc
Articles: 2 | Text for article 1 | Text for article 2 | Text for article 3 | etc
Themes: 1 | Local | Sport | Business | etc
Themes: 2 | Business | Sport | Local | etc
So here, In Post 1, Article 1
is a post about the local area and Article 2
is about Sport, whereas in Post 2, Article 1
is about the Business and Article 2
is about Sport.
What I would like to do is have a PHP script which can select any article from any column based on it's theme.
So for instance:
SELECT ( CELL ) FROM articles WHERE ( THE CORESPONDING COLUMN IN THEMES ) = 'Business'
I'd also like to be able to select multiple rows. (SELECT * FROM articles LIMIT 12
).
Can anyone advise or help with this? Thanks.