I\'ve got a table with some rows that contain 3 fields (category, title, image). At first I created a foreach loop that returned some html with the information from each of the
Either use the WHERE
clause as asifrc suggested.
Or do something like this
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
if($row['category'] == 'category1') {
// do some stuff example
$html_output .= 'Important category: ' . $row['title'] . '
';
} else if($row['category'] == 'category2') {
// do other stuff
$html_output .= 'Not important category: ' . $row['title'] . '
';
}
}