The following output shows the results of the first query, but not the second query. When I query without using a function, it works fine.
function builtFooter($catactive, $catlink) { global $conn; $sql = "SELECT catid, catname_de AS name, catlink as link, extern, extlink FROM categories WHERE catactive=? AND catlink!=? ORDER BY catsort"; $stmt = $conn->prepare($sql); $stmt->bind_param("ss", $catactive, $catlink); $stmt->execute(); $result = $stmt->get_result(); while ($cat = $result->fetch_assoc()) { $resArr[] = $cat; echo '' . $cat['name'] . '
'; $cities = "SELECT COUNT(a.ad_id) AS ANZ,a.region, b.city, b.citylink FROM ads a, neueorte b WHERE a.zeigen=? AND a.gesperrt=? AND FIND_IN_SET(?, a.portale) AND a.catid=? AND b.po_id=a.region GROUP BY a.region ORDER BY ANZ DESC LIMIT 0,50"; $stmt = $conn->prepare($cities); $zeigen = 'ja'; $gesperrt = 'no'; $category = $cat['catid']; $stmt->bind_param("ssss", $zeigen, $gesperrt, $portalnumber, $category); $stmt->execute(); $result = $stmt->get_result(); while ($city = $result->fetch_assoc()) { $resArr[] = $city; echo ' ' . $city['city'] . '
'; } } } builtFooter('yes', 'markt');
These queries all work fine and I get the results I want:
But when I build a function, I can't get the results of the second query:
I have the categories, ads and neueorte tables. I want to build footer links so I want to have the categories as h3 tags and then group by city where I have the city where the ad is placed. Hope I'm doing it right, I'm new to this page.