【问题标题】:displaying data on php在php上显示数据
【发布时间】:2018-01-14 15:55:19
【问题描述】:

>

</tr>
<?php
$conn = mysqli_connect("localhost", "root", "", "engine");
if ($conn-> connect_error) {

    die("connection files:" . $conn-> connect_error);
}

$sql = "SELECT location , brand, model, origin, mfgdate from engines ";
$result = $conn-> query($sql);

if ($result-> num_rows > 0){
    while ($row = $result-> fetch_assoc()){
        echo "<tr><td>". 
        $row["location"] . "</td<td>" . 
        $row["brand"] . "</td><td>". 
        $row["model"] . "</td><td>". 
        $row["origin"] . "</td><td>". 
        $row["mfgdate"] . "</td></tr>";
    }
    echo "</table>";
}
else{
    echo "0 result";
}
$conn->close();
?>



</table>

when code is execute

其实 "test"=location test1=brand test2=model test3= origin and date enter is =mfgdate

请帮我安排餐桌

【问题讨论】:

  • 只需修复此行中缺少的&gt;$row["location"] . "&lt;/td&gt;&lt;td&gt;" .
  • 您使用的是哪个 IDE?我很惊讶它没有显示 colo(u)r 的错误

标签: php mysql


【解决方案1】:

代替

$row["location"] . "</td<td>" 

使用

$row["location"] . "</td><td>"

(标签中缺少结尾&gt;)。

【讨论】:

    【解决方案2】:

    您遇到了与语法错误有关的问题。

    你错过了一个 > 关闭一个 td。

        </tr>
    <?php
    $conn = mysqli_connect("localhost", "root", "", "engine");
    if ($conn-> connect_error) {
    
        die("connection files:" . $conn-> connect_error);
    }
    
    $sql = "SELECT location , brand, model, origin, mfgdate from engines ";
    $result = $conn-> query($sql);
    
    if ($result-> num_rows > 0){
        while ($row = $result-> fetch_assoc()){
            echo "<tr><td>". 
            $row["location"] . "</td><td>" . 
            $row["brand"] . "</td><td>". 
            $row["model"] . "</td><td>". 
            $row["origin"] . "</td><td>". 
            $row["mfgdate"] . "</td></tr>";
        }
        echo "</table>";
    }
    else{
        echo "0 result";
    }
    $conn->close();
    ?>
    </table>
    

    然而,最好的做法是在 php 中生成数据并发送到客户端服务器,然后将值放入表中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-05
      相关资源
      最近更新 更多