我是php的新手,我正在尝试创建自己的php shop cart.经过一些研究后,我陷入了下面的"功能产品"中,因为在我看来它不能正常工作.我希望在我的mysql数据库上看到我的产品的名称,但它没有显示任何内容.我的用户名是noivaemd_etalhes,我使用的是正确的密码,我的数据库名称是noivaemd_cart,我在这个数据库中创建了一个名为Products的表,其中包含我的产品列表.任何人都可以帮我弄清楚我在下面的php指令上做错了什么?我感谢任何帮助.
<?php
session_start();
$page = 'index.php';
function products() {
$con = mysqli_connect("localhost", "noivaemd_etalhes", "mypassword", "noivaemd_cart") or die (mysqli_error());
$res = mysqli_query($con, "SELECT id, name, description, price FROM Products WHERE quantity > 0 ORDER BY id DESC");
if (mysqli_num_rows($res)==0) {
echo "<font family=verdana><font size=6px><font color= #90882C><font style=normal><font variant= normal><br>No products available<br></font>";
}
else{
while($get_row = mysqli_fetch_assoc($res)) {
echo '<p>'.$res['name'].'</p>';
}
}
}
?>
Run Code Online (Sandbox Code Playgroud) php ×1