There are two tables.
In one ad heading: board_cats with the structure: |cat_id|cat_title|...|
In the other ads themselves: board_items with the structure |item_id|item_title|...|item_cat_id|
I choose the list of rubrics alphabetically
$sql = "SELECT * FROM board_cats ORDER BY cat_title ASC"; $result = $inDB->query($sql) ; if ($inDB->num_rows($result)){ while($item = $inDB->fetch_assoc($result)){ $massiv[] = $item; } } it works, it's simple.
Now it is necessary to add a counter to each derived category, how many ads there are. And here, as I understand it, we need JOINs, in which I haven’t been booming, although I’ve tried to figure it out using examples.
That is, the logic is as follows - in board_items we are looking for announcements that have item_cat_id = cat_id , count them, and write the amount into an array. But how to do it?
Thank you in advance.