虽然在里面而在里面

时间:2017-10-06 01:14:54

标签: php

编辑 - 解决方案:将(function() { // input here contains c.data from client script if (input && input.cases) { for (var i = 0; i < input.cases.length; i++) { // write to system log gs.info(input.cases[i]); } } }); 移至第一次之前
我制作了这个代码来展示比赛的记分牌 第一次:获取所有类别。
第二个时间:从类别中获取所有子类别 第三个:获取子类别的所有记录 问题是:
如果DESC的第一个循环顺序是仅打印第一个结果并对此类别执行 如果我改为ASC,它什么都不打印 注意:并非每个子类别都有记录。

$sub = '';

1 个答案:

答案 0 :(得分:0)

也许它可以帮助重新格式化查询以反映蝙蝠的变量值(而不是以后处理它们 - 在软件中可能是也可能不是这样): 取代

  

$ querysub = $ db-&gt; query(&#34; SELECT id,id_category,name FROM category_sub WHERE id_category = $ categoryid&#34;);

  

$ querysub = $ db-&gt; query(&#34; SELECT id,id_category,name FROM category_sub WHERE id_category =&#34;。$ categoryid);

并替换

  

$ record = $ db-&gt; query(&#34; SELECT records.id as id,competitor.name as competitionitor,category.name as category,category_sub.name as subcategory,records.amplifier as amplifier,records。扬声器作为扬声器,records.battery作为电池,records.decibels作为分贝,records.car作为汽车FROM记录LEFT JOIN竞争者ON竞争者.id = records.id_competitor LEFT JOIN类别ON records.id_category = category.id LEFT JOIN category_sub ON记录.id_subcategory = category_sub.id WHERE category_sub.name =&#39;。$ subcategoryname。&#39; ORDER BY points ASC&#34;);

  

$ record = $ db-&gt; query(&#34; SELECT records.id as id,competitor.name as competitionitor,category.name as category,category_sub.name as subcategory,records.amplifier as amplifier,records。扬声器作为扬声器,records.battery作为电池,records.decibels作为分贝,records.car作为汽车FROM记录LEFT JOIN竞争者ON竞争者.id = records.id_competitor LEFT JOIN类别ON records.id_category = category.id LEFT JOIN category_sub ON记录.id_subcategory = category_sub.id WHERE category_sub.name =&#39;&#34;。$ subcategoryname。&#34;&#39; ORDER BY points ASC&#34;);

此外,您要停止在此行执行整个代码:

if(!is_numeric($subcategory['id'])){
    continue;
}

continue替换为break以仅停止该次迭代并继续下一次迭代:

if(!is_numeric($subcategory['id'])){
    break;
}