【问题标题】:How can I arrange the materialize css cards in a row while those cards are holding data fetched from mysql database当这些卡片保存从 mysql 数据库中获取的数据时,如何连续排列具体化 css 卡片
【发布时间】:2018-12-05 19:36:20
【问题描述】:

我正在尝试将数据库中的数据提取到 Materialise CSS 卡中。我想要的是一排只有3张牌。在一行中的第三张牌之后,它应该在下一个新行中自动显示接下来的 3 张牌。

And this is how I want to display it 这是我的快照代码。

<?php
        $cnt=1;
        $sql=mysqli_query($db,"select * from addevent");
        $row=mysqli_num_rows($sql);

        while($row=mysqli_fetch_array($sql)){
                echo"<div class='card amber lighten-1' style='grid-auto-flow:row; width:300px;margin-left:10px;'>
                                <div class='card-content'>";
                                    echo "<span class='card-title activator teal-text text-darken-3'>".$row['EventName']."<i class='material-icons right'>more_vert</i></span>";
                                    echo "<h6 class='teal-text text-darken-3'>".$row['Oname']."</h6>";
                                    echo "<h5 class='brown-text text-lighten-3'>".$row['EventDate']." | ".$row['EventTime']."</h5>";
                                    echo "<p class='deep-orange-text text-lighten-1'>".$row['EventAddress']."</p>";
                                echo"</div>";

                                echo"<div class='card-reveal'>";
                                    echo "<span class='card-title orange-text text-lighten-1'>".$row['EventName']."<i class='material-icons right'>close</i></span>";
                                    echo "<p class='teal-text text-lighten-2'>".$row['AboutEvent']."</p>";
                                echo"</div>";
                        echo"</div>";

            }
            echo"</div>";
    ?>

【问题讨论】:

  • 那么你有没有尝试过真正做你想做的事?
  • 我发的都是我做的。
  • 我理解,但它确实没有尝试实现“一行只有3张卡片。在一行第三张卡片之后,它应该在下一个新行中显示接下来的3张卡片”。没有进一步的观察,不清楚是什么部分导致了您的问题。
  • 我添加了另一个快照,以便更清楚地了解我想要如何显示它。

标签: php html css mysql materialize


【解决方案1】:

只需让计数器在每次迭代中运行。 一旦计数器达到 3,您只需关闭当前行并打开一个新行。 之后不要忘记将计数器重置为 1。

【讨论】:

    猜你喜欢
    • 2020-11-04
    • 1970-01-01
    • 1970-01-01
    • 2022-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多