为什么 PHP 输出没有显示在网页上?
Why the PHP output is not displaying on webpage?
我没有从这个 php 代码中得到任何输出,显示空白页
<?php
include 'conn.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include('callheadcss.php');?>
</head>
<body>
Div 显示 php 输出
<div id="slidey">
<ul>
<?php
使用准备语句
$stmt = $con->prepare('SELECT * FROM sliderimg');
$stmt->execute();
$result = $stmt->get_result();
$numRows = $result->num_rows;
if($numRows > 0)
{
while ($row = $result->fetch_assoc())
{
$imgpath=$row['SliderImg'];
echo '<li><img src="'.$imgpath.'"><p class="title">'. $row['Event_name'] .'</p><p class="description">'. $row['Eventdate'] .'</p></li>';
}
}
?>
</ul>
</div>
</body>
滑块脚本
<script src="designcss/js/jquery.slidey.js"></script>
<script src="designcss/js/jquery.dotdotdot.min.js"></script>
<script type="text/javascript">
$("#slidey").slidey({
interval: 8000,
listCount: 5,
autoplay: false,
showList: true
});
$(".slidey-list-description").dotdotdot();
</script>
快速建议:
- 在
<body>
标签之后添加一些虚拟文本,例如 lorem ipsum:如果它没有显示,那么您的问题与您的 PHP 脚本无关
- 使用
var_dump($numRows)
确保最少使用一行
$stmt->execute();
$result = $stmt->get_result();
$result->store_result();
$numRows = $result->num_rows;
来自 php.net :
Returns the number of rows in the result set. The use of mysqli_stmt_num_rows() depends on whether or not you used mysqli_stmt_store_result() to buffer the entire result set in the statement handle.
If you use mysqli_stmt_store_result(), mysqli_stmt_num_rows() may be called immediately.
尝试使用
打印$row
print_r($row);
这将以数组格式打印 $row,这样您就可以看到所有数据是否到达
我没有从这个 php 代码中得到任何输出,显示空白页
<?php
include 'conn.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include('callheadcss.php');?>
</head>
<body>
Div 显示 php 输出
<div id="slidey">
<ul>
<?php
使用准备语句
$stmt = $con->prepare('SELECT * FROM sliderimg');
$stmt->execute();
$result = $stmt->get_result();
$numRows = $result->num_rows;
if($numRows > 0)
{
while ($row = $result->fetch_assoc())
{
$imgpath=$row['SliderImg'];
echo '<li><img src="'.$imgpath.'"><p class="title">'. $row['Event_name'] .'</p><p class="description">'. $row['Eventdate'] .'</p></li>';
}
}
?>
</ul>
</div>
</body>
滑块脚本
<script src="designcss/js/jquery.slidey.js"></script>
<script src="designcss/js/jquery.dotdotdot.min.js"></script>
<script type="text/javascript">
$("#slidey").slidey({
interval: 8000,
listCount: 5,
autoplay: false,
showList: true
});
$(".slidey-list-description").dotdotdot();
</script>
快速建议:
- 在
<body>
标签之后添加一些虚拟文本,例如 lorem ipsum:如果它没有显示,那么您的问题与您的 PHP 脚本无关 - 使用
var_dump($numRows)
确保最少使用一行
$stmt->execute();
$result = $stmt->get_result();
$result->store_result();
$numRows = $result->num_rows;
来自 php.net :
Returns the number of rows in the result set. The use of mysqli_stmt_num_rows() depends on whether or not you used mysqli_stmt_store_result() to buffer the entire result set in the statement handle.
If you use mysqli_stmt_store_result(), mysqli_stmt_num_rows() may be called immediately.
尝试使用
打印$rowprint_r($row);
这将以数组格式打印 $row,这样您就可以看到所有数据是否到达