For a website I am working on I use the following 2 tables to manage the different widgets on the site:
CREATE TABLE `site_widgets` (
`widget_id` smallint(6) NOT NULL,
`widget_name` varchar(64) NOT NULL,
`isActive` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `widget_content` (
`content_id` smallint(6) NOT NULL,
`widget_id` smallint(6) NOT NULL,
`language_abbr` char(2) NOT NULL,
`heading` varchar(128) DEFAULT NULL,
`content` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Where the first table holds the identity of each widget (more for admin purpose), The second table holds the actual content for each widget. Each widget can have multiple rows in this table. How do I query this table to get those rows from the table so I can use them separated. For example I have a widget called Collage. In the table I have four rows for this widget. If I use a basic query like
SELECT *
FROM widget_content
WHERE widget_id = 3
and after that use a loop in the widget I offcource get the 4 rows. But I need the content from each row on different places within the widget. So how do I query the database so I can use each row as separated content. Thank you in advance