I'm trying to pull information from my database based on the values of a specific column. They're being pulled into different categories based on this column, but some of the rows have to be pulled several times as they are part of several categories or "sections". I'm using the datatype SET for the category column so I can set multiple sections easily.
$code_sections = array (
'Section 1' => 'section_1',
'Section 2' => 'section_2',
'Section 3' => 'section_3',
'Section 4' => 'section_4',
'Section 5' => 'section_5',
'Section 6' => 'section_6',
'Section 7' => 'section_7',
);
foreach($code_sections as $name => $section) {
$query="SELECT * FROM `attributes` WHERE `section`= '$section' ";
$results = mysqli_query($conn, $query) or exit(mysqli_error());
echo '<h3>' . $name . '</h3>';
echo '<div class="auto-grid">';
while ($row = mysqli_fetch_array($results)) {
echo '$row["name"]';
}
echo '</div>';
}
This works if I have data in the column that matches the array exactly, which is basically when the row is only part of ONE section. If it's part of two sections it will not be pulled at all.