5

Iframe does not work in PHP?

 2 years ago
source link: https://www.codesd.com/item/iframe-does-not-work-in-php.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Iframe does not work in PHP?

advertisements

This question already has an answer here:

  • Echo inside an element attribute? 1 answer

I have a php file which will show a list of images/products dynamically from the mysql database! This bit works just fine.

but I am trying to but the command in the iframe so I can create a slideshow affect using iframe!

but when I put the iframe around the command it doesn't work for some reason! it will open a 404 page on my 000web hosting server!!

here is my code:

<?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>

any help would be grately appreciated as I am almost done with this project.


Just loose the iFrame and echo the $dyn_table inside the table you already have?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK