我有一个 php 文件,它将动态显示来自 mysql 数据库的图像/产品列表!这一点工作得很好。
但我正在尝试使用 iframe 中的命令,因此我可以使用 iframe 创建幻灯片效果!
但是当我将 iframe 放在命令周围时,由于某种原因它不起作用!它将在我的 000web 托管服务器上打开一个 404 页面!!
这是我的代码:
<?php
include "config/connect_to_mysql.php";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 10");
$i = 0;
// Establish the output variable
$dyn_table = '<table border="0" cellpadding="6">';
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
if ($i % 5 == 0) { // if $i is divisible by our target number (in this case "5")
$dyn_table .= '<tr><td><div style="position:relative" class="shadow tr" id="products_holder"><div style="position:absolute;left:-10px;top:-12px;">
<img src="images/best.png" width="97" height="94" />
</div><a href="product.php?id=' . $id . '"><img style=" margin:5px; border:#ccc 1px solid" src="inventory_images/' . $id . '.jpg" width="150" height="160"/></a></div></td>';
} else {
$dyn_table .= '<td><div style="position:relative" class="shadow tr" id="products_holder"><div style="position:absolute;left:-10px;top:-12px;">
<img src="images/best.png" width="97" height="94" />
</div><a href="product.php?id=' . $id . '"><img style=" margin:5px; border:#ccc 1px solid" src="inventory_images/' . $id . '.jpg" width="150" height="160"/></a></div></div></td>';
}
$i++;
}
$dyn_table .= '</tr></table>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<script src="scripts/modernizr-2.6.1.min.js"></script>
<title>site.com</title>
<style type="text/css">
</style>
</head>
<body>
<div align="center" id="wrapper">
<?php include_once("temps/header.php"); ?>
<div id="content">
<div id="apDiv1">
<h2>Top pros</h2></div>
<table width="100%" border="0" cellspacing="0" cellpadding="17">
<tr>
<td width="2%" height="20"> </td>
<td width="98%" height="20"><p><?php echo $dyn_table; ?></p>
</tr>
</table>
<table align="center" style=" table-layout:fixed; background-image:url(images/secondSection.png);" height="82" width="100%" border="0" cellspacing="10" cellpadding="10">
<tr>
<td width="2%" height="31"> </td>
<td style="vertical-align:top" align="center" width="28%"><div id="apDiv555" class="top_btns">
<h6 class="shadow"> More Products</h6>
</div></td>
<td style="vertical-align:top" align="center" width="70%"><div id="apDiv55" class="top_btns">
<h6><span class="shadow"><a href="#"> Search By Clothing</a> | <a href="#">Search By Retailers</a></span></h6>
</div></td>
</tr>
</table>
<table style="background-image: url(images/tbl_bg.png); background-repeat: repeat-x;" height="350px" width="100%" border="0" cellspacing="12" cellpadding="0">
<tr>
<td width="3%"></td>
<td width="97%"><iframe src="<?php echo $dyn_table; ?>" height="250" width="100%" ></iframe></td>
</tr>
</table>
</table>
<table height="100" width="100%" border="0" cellspacing="17" cellpadding="17">
<tr>
<td> </td>
</tr>
</table>
</div>
</div>
<?php include_once ("temps/footer.php"); ?>
</body>
</html>
任何帮助将不胜感激,因为我几乎完成了这个项目。
钍