在LIST STYLE中以1行显示结果

时间:2014-04-28 06:35:50

标签: php html

这里是我的代码,用于检索数据并使用

  • 在一行中显示图像库。

    <?php
    require('database_connection.php');
        if (@mysqli_connect_errno())
        {
           echo "Failed to connect to MySQL: " . mysqli_connect_error();
        }
        $latest_tyres = "SELECT IMLITM, BRAND, PATTERNS, WIDTH, SZ FROM tblInventory WHERE NOT AR='0' AND LATEST='L'";
        echo "<ul style='list-style:none;display:inline;padding:0'>";
        while ($row = mysqli_fetch_assoc($latest_tyres)) 
        {
    
            echo "<li style='width:230px;height:320px;background-color:green'>";
            echo "<div style='width:220xp;height:320px;background-color:black;margin-left:auto;margin-right:auto'>";
            echo "</div>";
            echo "</li>";
        }
        echo "</ul>";
        mysqli_close($mydatabase);
    ?>
    

    由于代码的结果应该产生如下的HTML:

    <ul style='list-style:none;display:inline;padding:0'>
       <li style='width:230px;height:320px;background-color:green'>
           <div style='width:220xp;height:320px;background-color:black;margin-left:auto;margin-right:auto'>
           </div>
       </li>
    </ul>
    

    但在我的HTML中,它只显示为空代码:

    <ul style="list-style: none; display: inline; padding: 0px;"/>
    

    这里是QUERY OUTPUT:

    ===================================================
    |  IMLITM  |  BRAND  | PATTERNS  |  WIDTH  |  SZ  |
    ===================================================
    | LRCO095  |  CON    |    R50    |   200   |  16  |
    ---------------------------------------------------
    | LB1111   |  FALKEN |    R70    |   100   |  18  |
    ---------------------------------------------------
    
  • 1 个答案:

    答案 0 :(得分:0)

    我认为你在循环开始之前忘了使用mysqli_query函数。 http://in2.php.net/mysqli_query

    使用以下代码。

    $result = mysqli_query($latest_tyres);
    echo "<ul style='list-style:none;display:inline;padding:0'>";
    while ($row = mysqli_fetch_assoc($result))
    
    {
       // Your html code
    }
    echo "</ul>";