<?php
set_time_limit(5000);
ob_start();
session_start();
include('connection_config.php');
?>
<!DOCTYPE html>
<html>
<title>mi Adda Portal</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="sidenav.js"></script>
<link rel="stylesheet" href="headings.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Rancho&effect=shadow-multiple">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="w3-white w3-content" style="max-width:1600px">
<header>
<div class="w3-container w3-red w3-center">
<a href="home.php" style="text-decoration:none;"><h2 style="text-align:left; float:center;font-family:Times New Roman;">WAP Portal</h2>
</div>
</header>
<!-- !PAGE CONTENT! -->
<body>
<div class="bgimage">
<div class="w3-main bgimage" style="margin:auto;text-align:center">
<h4 class="w3-Rancho font-effect-shadow-multiple" style="text-align:center;margin: auto; padding-top:auto;">Fashion Wallpapers</h4>
<hr style="display: block; margin:0.5em 0.5em auto auto; border-style: inset;border-width: 1px;"><br>
<div>
<table width="100%" align="center" cellpadding="15" cellspacing="20">
<tr>
<td align="center" valign="middle">
<a href="">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/kkf_in_fng004.gif" height="135" width="135">
</a>
</td>
<td align="center" valign="middle">
<a href="#">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/kk_in_fng002.gif" height="135" width="135">
</a></td>
<tr>
<td align="center" valign="middle">
<a href="#">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/ss_in_fng015.gif" height="135" width="135">
</a>
</td>
<td align="center" valign="middle">
<a href="#">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/uk_in_fng001.gif" height="135" width="135">
</a></td>
<tr>
<td align="center" valign="middle">
<a href="#">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/uk_in_fng003.gif" height="135" width="135">
</a>
</td>
<td align="center" valign="middle">
<a href="#">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/uk_in_fng005.gif" height="135" width="135">
</a>
</td>
</tr>
</table>
</div>
<br/>
<?php
$connect_error = 'Sorry, we\'re experiencing connection issues.';
$con=mysqli_connect("localhost", "root", "12345","miadda") or die("Can not connect to database: ".mysql_error());
mysqli_select_db($con,"miadda") or die("Can not select the database: ".mysql_error());
$sql = "select * from miadda";
// the result of the query
$result = mysqli_query($con,$sql) or die("Invalid query: " .mysqli_error($connect_error));
// Header for the image
while ($row = mysqli_fetch_array($result))
{
//$image=$row ['CONTENT_PATH'];
echo '<img src="/WAPContent/fashion/fashionwallpapers/500x500/'.$row['CONTENT_PATH'].'" width="100" height="100">';
}
?>
</div>
<!-- Pagination -->
<div class="w3-center w3-padding-32">
<div class="w3-bar">
<a href="void:javascript" class="active w3-bar-item w3-button-disabled">1</a>
<a href="http://localhost/miadda%20portal/fashion_wallpaper2.php" class="w3-bar-item w3-button">2</a>
<a href="http://localhost/miadda%20portal/fashion_wallpaper3.php" class="w3-bar-item w3-button">3</a>
</div>
</div>
<!--end of pagination-->
<style>
.w3-bar a.active
{
background-color: #4CAF50;
color: white;
}
..w3-bar a:hover:not(.active) {
background-color: #ddd;
}
.bgimage {
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
/* First image (Logo. Full height) */
.bgimage {
background-image: url('bg.jpg');
min-height: 100%;
opacity:1;
}
</style>
</body>
<!--Footer-->
<footer>
<div class="w3-red w3-center" style="margin-bottom:-15px;margin-top:15px;padding-top:8px;padding-bottom:8px;">
<a href="home.php" class="footer_home" style="text-decoration:none;color:white;">| Home |</a>
</div>
</footer>
</div>
<!-- End page content -->
</html>
<?php
ob_flush();
?>
有人可以帮助我在这部分代码中出错的地方:
<?php
$connect_error = 'Sorry, we\'re experiencing connection issues.';
$con=mysqli_connect("localhost", "root", "12345","miadda") or die("Can not connect to database: ".mysql_error());
mysqli_select_db($con,"miadda") or die("Can not select the database: ".mysql_error());
$sql = "select * from miadda";
// the result of the query
$result = mysqli_query($con,$sql) or die("Invalid query: " .mysqli_error($connect_error));
// Header for the image
while ($row = mysqli_fetch_array($result))
{
//$image=$row ['CONTENT_PATH'];
echo '<img src="/WAPContent/fashion/fashionwallpapers/500x500/'.$row['CONTENT_PATH'].'" width="100" height="100">';
}
?>
运行Web门户时,它不会显示任何错误。但是不显示图像。显示所有图像的图像边框,但显示不可用或损坏的图像。
以下是它如何显示的屏幕截图: enter image description here
应从数据库中提供的图像路径中检索图像: “/ WEBContent / fashion / fashionwallpapers /”栏目CONTENT_PATH
,完整路径为:/ WAPContent / fashion / fashionwallpapers / 500x500 /
附件是MySQL表的屏幕截图,我正在从事时尚类:
请帮帮我...提前致谢。
答案 0 :(得分:0)
数据库中的内容路径实际上是:内容路径。图像名称位于字段content_name。
中<?php
$connect_error = 'Sorry, we\'re experiencing connection issues.';
$con=mysqli_connect("localhost", "root", "12345","miadda") or die("Can not connect to database: ".mysql_error());
mysqli_select_db($con,"miadda") or die("Can not select the database: ".mysql_error());
$sql = "select * from miadda where CONTENT_PATH<>'NA'";
// the result of the query
$result = mysqli_query($con,$sql) or die("Invalid query: " .mysqli_error($connect_error));
// Header for the image
while ($row = mysqli_fetch_array($result))
{
$image=$row ['CONTENT_PATH'].$row['CONTENT_NAME'];
//use a relative path
if(0 === strpos($image,"/")) $image = substr($image, 1);
$image = mb_substr($image, 0, mb_strlen($image)-2) + "/";
echo '<img src="'.$image.'" width="100" height="100">';
}
?>