0

我遇到了一个问题

$divider_div = ($last_topic % 2 == 0) ? '
<div class="clear"></div>' : FALSE ;

应该在每秒钟发生一次之后放置,但它会以某种方式中断序列。

我做错了什么?

任何建议都非常受欢迎

这是我的脚本

$category_topic_query = 'SELECT l.category_name, l.category_folder, l.category_page, f.parentpageID, f.ImagePath, f.referring_url, f.templateTitle FROM lcategories l INNER JOIN Files f ON f.parentpageID = l.ID WHERE f.pageID = "0" ORDER BY f.parentpageID';
    $resc = $db->prepare($category_topic_query);
    $resc->execute();
$last_topic = NULL;
while ($category_topic = $resc -> fetch()){
    $category_topic_ID = $category_topic['parentpageID'];
    if($category_topic_ID !== $last_topic) {
    $category_topic_name = str_replace("&", "&amp;", $category_topic['category_name']);
    $category_topic_url = DST.$category_topic['category_folder'].DS.$category_topic['category_page'];
    $divider_div = ($last_topic % 2 == 0) ? '
<div class="clear"></div>' : FALSE ;
    $first_ul = ($category_topic_ID == 1) ? FALSE : '</ul>
</div>'.$divider_div ;
print<<<END
$first_ul
<div style="float: left; margin: 10px; width: 349px;">
<h2 class="h_unln"><a href="$category_topic_url">$category_topic_name</a></h2>
<ul class="arrow">

END;

$last_topic = $category_topic_ID;
}
    $links_array = ($category_topic['referring_url'] == NULL) ? FALSE :'<li><a href="'.DST.$category_topic['ImagePath'].DS.$category_topic['referring_url'].'">'.$category_topic['templateTitle'].'</a></li>';


print<<<END
$links_array

END;
}
print<<<END
</ul>
</div>
<div class="clear"></div>

END;

提前致谢

4

1 回答 1

0

好的,它已完成并按预期工作

    $category_topic_query = 'SELECT l.category_name, l.category_folder, l.category_page, f.parentpageID, f.ImagePath, f.referring_url, f.templateTitle FROM lcategories l INNER JOIN Files f ON f.parentpageID = l.ID WHERE f.pageID = "0" ORDER BY f.parentpageID';
    $resc = $db->prepare($category_topic_query);
    $resc->execute();
$last_topic = NULL;
$add_rowNum = 1;
while ($category_topic = $resc -> fetch()){
    $category_topic_ID = $category_topic['parentpageID'];
    if($category_topic_ID !== $last_topic) {
        $add_rowNum++;
    $category_topic_name = str_replace("&", "&amp;", $category_topic['category_name']);
    $category_topic_url = DST.$category_topic['category_folder'].DS.$category_topic['category_page'];
    $divider_div = ($add_rowNum % 2 == 0) ? '
<div class="clear"></div>' : FALSE ;
    $first_ul = ($category_topic_ID == 1) ? FALSE : '</ul>
</div>'.$divider_div ;
print<<<END
$first_ul
<div style="float: left; margin: 10px; width: 349px;">
<h2 class="h_unln"><a href="$category_topic_url">$category_topic_name</a></h2>
<ul class="arrow">

END;

$last_topic = $category_topic_ID;
}
    $links_array = ($category_topic['referring_url'] == NULL) ? FALSE :'<li><a href="'.DST.$category_topic['ImagePath'].DS.$category_topic['referring_url'].'">'.$category_topic['templateTitle'].'</a></li>';


print<<<END
$links_array

END;
}
print<<<END
</ul>
</div>
<div class="clear"></div>

END;

我的错误是我实际上是$add_rowNum++;在错误的地方添加

感谢你们所有人,尤其是 CBroe,因为他确实让我意识到关于 ID 的一件非常重要的事情

于 2013-09-14T20:26:24.737 回答