mySql get different rows with same foreign key as separated content

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'

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

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

  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

you would run that same query and then write a loop to handle each row separately

maybe some kind of array, eh

maybe this is a php question?

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.