I'm not sure how to search this issue I'm having nor if I'm using the right terminology.
I have a table with various records and each record have a category set. I want to query the table once and output the results in the relevant sections on a web page.
What I have done thus far:
$result_f1 = $db->query("SELECT * FROM files WHERE user_id = $user_id ") or die('cannot show tables');
... some html ...
if($result_f1) {
while($row3 = $result_f1->fetch_object()) {
if ($row3->category == "image") {
echo '<div class="col-sm-6"><img class="img-responsive" src="/site/data/' .$user_id. '/',$row3->filename,'" alt="Photo"></div>';
}
}
}
...more html onto next section...
if($result_f1) {
while($row4 = $result_f1->fetch_object()) {
if ($row4->category == "vehicle") {
echo '<div class="col-sm-6"><img class="img-responsive" src="/site/data/' .$user_id. '/',$row4->filename,'" alt="Photo"></div>';
}
}
}
So the one section I want to match records with the "image" category and the next section on the "vehicle" section.
Using the above code, it only displays records of the while loop, not the second loop. What should I be doing different?
category like "image", the second one withcategory like "vehicule"