我正试图从mysqli的php中显示一些信息。在localhost上说它连接但当我尝试显示数据侧边栏菜单消失。有什么帮助吗?
这是功能页面:
<?php
DEFINE('DB_USERNAME', 'root');
DEFINE('DB_PASSWORD', 'root');
DEFINE('DB_HOST', 'localhost');
DEFINE('DB_DATABASE', 'ecommerce');
$mysqli = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
if (mysqli_connect_error()) {
die('Connect Error ('.mysqli_connect_errno().') '.mysqli_connect_error());
}
echo 'Connected successfully.';
$mysqli->close();
?>
<?php
global $mysqli;
$get_cats = "select * from categories";
$run_cats = mysqli_query($mysqli, $get_cats);
while ($row_cats=mysqli_fetch_array($run_cats)){
$cat_id = $row_cats['cat_id'];
$cat_title = $row_cats['cat_title'];
echo "<li><a href='#'>$cat_title</a></li>";
}
?>
<?php
require "functions/functions.php";
?>
<html>
<head>
<title>My Online Shop</title>
<link rel="stylesheet" type="text/css" href="styles/reset.css">
<link rel="stylesheet" type="text/css" href="styles/style.css">
</head>
<div class="main_wrapper">
<div class="header_wrapper">
<img id="logo" src="images/logo.gif">
<img id="banner" src="images/banner.jpg">
</div>
<div class="menubar">
<ul id="menu">
</ul>
<div id="form">
<form method="get" action="results.php" enctype="multipart/form-data">
<input type="text" name="user_query" placeholder="Search Product">
<input type="submit" name="search" value="search">
</form>
</div>
</div>
<div class="content_wrapper">
<div id="sidebar">
<div id="sidebar_title">Categories</div>
<ul id="cats">
<?php getCats(); ?>
</ul>
<div id="sidebar_title">Brands</div>
<ul id="cats">
<li><a href="#">HP</a></li>
<li><a href="#">DELL</a></li>
<li><a href="#">Motorola</a></li>
<li><a href="#">Sony Ercisson</a></li>
<li><a href="#">LG</a></li>
<li><a href="#">Apple</a></li>
</ul>
</div>
</div>
<div id="content_area">This is content area</div>
<div id="footer">This is the footer</div>
</div>
</div>