将数据提取为表格格式

时间:2016-07-18 05:32:55

标签: php html mysql database

我试图以表格格式从数据库中获取数据。我把count变量作为行数和5列。当我执行此查询时,所有结果都以多行和单列的形式获取。 这是我的代码:

<?php
include("connect.php");
$all_product = mysqli_query($connect, "SELECT * FROM product WHERE user_id='$fetch_user_id'");
echo '<table style="background-color:white; margin-left:50px; margin-right:50px;">';
$count = mysqli_num_rows($all_product);
$count = ($count / 5) + 1;

for ($i = 0; $i < $count; $i++) {
    echo "<tr[$i]>";

    for ($m = 0; $m < 5; $m++) {
        echo "<td[$m]>";

        while ($all = mysqli_fetch_array($all_product)) {
            echo '<img src="' . $all['image'] . '" width="150px" height="150px" />
                <div class="search_details">
                <figcaption>' . $all['name'] . '</figcaption>
                <figcaption>by ' . $all['brand'] . '</figcaption><figcaption>&#8360;' . $all['price'] . '</figcaption>
                <figcaption>Save: &#8360;' . $local_price . ', (' . $all['discount'] . '%)</figcaption><figcaption>In stock:' . $all['stock'] . '</figcaption></div>';
        }

        echo "</td[$m]>";
    }

    echo "</tr[$i]>";
}

echo "</table>";
?>

有任何帮助吗?我哪里错了? 提前谢谢

1 个答案:

答案 0 :(得分:0)

我希望这会有所帮助:

 /// <summary>
    /// Reruns failed test cases
    /// </summary>
    /// <param name="run">Test run to process</param>
    /// <returns>Iterable list of test results which were reset</returns>
    public IEnumerable<ITestCaseResult> ReRunFailed(ITestRun run)
    {
        run.Refresh();
        var list = new List<ITestCaseResult>();
        foreach (var result in run.QueryResults().Where(result => result.Outcome == TestOutcome.Failed))
        {
            result.Reset();
            list.Add(result); 
        }
        return list;
    }