首页 > 解决方案 > PHP循环一个队列数据,并在第一个可见子DIV处输出当前队列号

问题描述

我有一个表名queue,我正在使用 PHP 来获取所有队列数据,数据库中有 9 条数据记录。

$qid = 20;
$fetchall = DB::fetch_all("SELECT * FROM ....");//discuz template language, = mysqli_fetch_all
foreach($fetchall as $ft){
    //some other code here
    $flist[] = $ft;
}

示例:在上述之后query,我有18,19,20,21,22,23,24,25,26. 现在我当前的队列号码是20,所以我希望号码20显示在 DIV 的第一个号码,下图是我想在网页中显示的内容。

<div id="parent" style="width:100px">
    <div id="child">
        <!--I'm using discuz template language to loop $flist here-->
        <div>18</div><!--hidden-->
        <div>19</div><!--hidden-->
        <div>20</div><!--show this at the first left-->
        <div>21</div><!--show this if parent width enough, else hidden-->
        <div>22</div><!--show this if parent width enough, else hidden-->
        <div>23</div><!--show this if parent width enough, else hidden-->
        <div>24</div><!--show this if parent width enough, else hidden-->
        <div>25</div><!--show this if parent width enough, else hidden-->
        <div>26</div><!--show this if parent width enough, else hidden-->
    </div>
</div>

由于18and19小于20,所以让它们在父 DIV 的外侧。

在此处输入图像描述

标签: phphtmlcss

解决方案


推荐阅读