0

mysql データベースから動的に画像/製品のリストを表示する php ファイルがあります。このビットは問題なく動作します。

しかし、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">&nbsp;</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">&nbsp;</td>
    <td style="vertical-align:top" align="center" width="28%"><div id="apDiv555" class="top_btns">&nbsp;&nbsp;&nbsp;&nbsp;
        <h6 class="shadow">&nbsp;More Products</h6>
    </div></td>
    <td style="vertical-align:top" align="center" width="70%"><div id="apDiv55" class="top_btns">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <h6><span class="shadow"><a href="#">&nbsp;&nbsp;&nbsp;Search By Clothing</a> &nbsp;|&nbsp;&nbsp;<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>&nbsp;</td>
    </tr>
</table>

</div>

</div>
<?php include_once ("temps/footer.php"); ?>
</body>
</html>

私はこのプロジェクトをほぼ完了しているので、どんな助けでも感謝します。

4

2 に答える 2

1

iFrame を緩めて、既存のテーブル内に $dyn_table をエコーするだけですか?

于 2013-02-25T21:12:11.673 に答える
0

あなたは iframe が何を意味するのかを認識していないかもしれません:

    <!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">&nbsp;</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">&nbsp;</td>
        <td style="vertical-align:top" align="center" width="28%"><div id="apDiv555" class="top_btns">&nbsp;&nbsp;&nbsp;&nbsp;
            <h6 class="shadow">&nbsp;More Products</h6>
        </div></td>
        <td style="vertical-align:top" align="center" width="70%"><div id="apDiv55" class="top_btns">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <h6><span class="shadow"><a href="#">&nbsp;&nbsp;&nbsp;Search By Clothing</a> &nbsp;|&nbsp;&nbsp;<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="my_iframe.php" height="250" width="100%" ></iframe></td>
        </tr>
    </table>
    </table>
    <table height="100" width="100%" border="0" cellspacing="17" cellpadding="17">
      <tr>
        <td>&nbsp;</td>
        </tr>
    </table>

    </div>

    </div>
    <?php include_once ("temps/footer.php"); ?>
    </body>
    </html>

    // Context on the my_iframe.php

    <?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 . '" target="_blank" onClick="window.open(this.href, this.target, 'width=300,height=400'); return false;"><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>';
    echo $dyn_table;
    ?>

iframe はまったく別のページなので、2 つのページを使用する必要があります....提案のように、1 つは html 用で、もう 1 つは iframe 用です....お役に立てば幸いです。

PS: a href を変更します ;)

サルドス ;)

于 2013-02-25T21:20:16.230 に答える