页面上的php详细信息显示问题

时间:2018-03-29 12:38:06

标签: php mysql

我试图在php页面上显示mysql的详细信息,但没有显示任何内容请有人帮忙。我已经按照教程并重新检查了代码,但仍未显示结果

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>test</title>
<link rel="stylesheet" href="system/css/global.css">
<link class="colour" rel="stylesheet" href="system/css/colour-blue.css">
<link class="pattern" rel="stylesheet" href="system/css/pattern-china.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
</head>
<?php
include 'header.php';
?>
<?php
include 'conn.php';

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);

    //Query
    $sql = "SELECT * FROM Hotels WHERE hotelid = '1'";

    $result = mysql_query("select hotelid, hotelname, location");

    while($row = mysqli_fetch_array($result)) 

$hotelname = $row[hotelname];

?>
<div id="container">
    <header>
        <div id="header">
            <div class="h1">
                <h1><span><?php echo $row['hotelname']; ?></span>

1 个答案:

答案 0 :(得分:0)

将此函数“mysqli_fetch_array()”替换为“mysqli_fetch_assoc()”。 - &GT;因为数组只能在不是字段名称的位置工作