以下输出显示了第一个查询的结果,但没有显示第二个查询的结果。当我不使用函数进行查询时,它可以正常工作。
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');
这些查询都正常工作,并且我得到了想要的结果:
但是当我构建一个函数时,我无法得到第二个查询的结果:
我有categories、ads和neueorte这些表。我想构建页脚链接,所以我想将类别作为h3标签,然后按城市分组,其中有放置广告的城市。希望我做得对,我是这个页面的新手。