Using DomPDF to generate table list from database - php

I have the following code for generating HTML content to PDF using DomPDF.and my problem focuses on this line
$pdf_content='<!DOCTYPE html PUBLIC "-//W3C//DTD...
The entire code
<?php
error_reporting(0);
require_once ('dompdf_config.inc.php');
$pdf_content='<!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" />
</head>
<style type="text/css">
#pdf_header, #pdf_container{ border: 1px solid #CCCCCC; padding:10px; }
#pdf_header{ margin:10px auto 0px; border-bottom:none; }
table{ width:580px; }
#pdf_container{margin:0px auto; }
.rpt_title{ background:#99CCFF; }
</style>
<body>
<div id="pdf_header" >
<table border="0" cellspacing="1" cellpadding="2">
<tr id="hdRow">
<td width="20%"><img src="space_age_header.jpg" style="width:250px" ></td>
<td width="30%" align="center">Sample File</td>
<td width="30%" align="left">Marimuthu<br>User Code : 179865420</td>
</tr>
</table>
</div>
<div id="pdf_container" >
<table border="0" cellspacing="1" cellpadding="2">
<tr align="center" bgcolor="pink" style="color:#FFF"><td colspan="3"><b>Your Statement Summery</b></td> </tr>
<tr bgcolor="#006" style="color:#FFF"><td colspan="3" align="left">Your Heading.</td></tr>
</table>
<table> <tr> <td> Name </td><td> Department</td><td>Total </td><td>Grade </td> </tr>
<tr> <td> Marimuthu </td><td> Admin</td><td>250 </td><td>A </td> </tr>
</div></body></html>'
;
$name = date("Ymd").rand().'.pdf';
$reportPDF=createPDF(12, $pdf_content, 'activity_Report', $name );
function createPDF($pdf_userid, $pdf_content, $pdf_For, $filename){
$path='UsersActivityReports/';
/*$rndNumber=rand();
$filename=$pdf_userid.date("Ymd").$rndNumber.'.pdf';*/
$dompdf=new DOMPDF();
$dompdf->load_html($pdf_content);
$dompdf->render();
$output = $dompdf->output();
file_put_contents($path.$filename, $output);
return $filename;
}
echo '<a href="UsersActivityReports/'.$name.'" > Download </a>';
?>
I have extracted the $pdf_content='<!DOCTYPE html PUBLIC "-//W3C//DTD... part to another page page.php and modified it to allow generating files from database using a do while loop.
<?php
include("../../Connections/dbConfig.php");
$query_record = mysqli_query($link,"SELECT * FROM `subjects`") or
die (mysqli_error($link));
$row_record = mysqli_fetch_assoc($query_record);
$totalRows_record = mysqli_num_rows($query_record);
?>
<!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" />
</head>
<style type="text/css">
#pdf_header, #pdf_container{ border: 1px solid #CCCCCC; padding:10px; }
#pdf_header{ margin:10px auto 0px; border-bottom:none; }
table{ width:580px; }
#pdf_container{margin:0px auto; }
.rpt_title{ background:#99CCFF; }
</style>
<body>
<div id="pdf_header" >
<table border="0" cellspacing="1" cellpadding="2">
<tr id="hdRow">
<td width="20%"><img src="space_age_header.jpg" style="width:250px" ></td>
<td width="30%" align="center">Sample File</td>
<td width="30%" align="left">Marimuthu<br>User Code : 179865420</td>
</tr>
</table>
</div>
<div id="pdf_container" >
<table border="0" cellspacing="1" cellpadding="2">
<tr align="center" bgcolor="pink" style="color:#FFF"><td colspan="3"><b>Your Statement Summery</b></td> </tr>
<tr bgcolor="#006" style="color:#FFF"><td colspan="3" align="left">Your Heading.</td></tr>
</table>
<table>
<tr> <td> Subject </td><td> Code </td><td>Total </td><td>Grade </td> </tr>
<?php do { ?>
<tr> <td> <?php echo $row_record['subject']; ?> </td><td> <?php echo $row_record['code']; ?> </td><td>250 </td><td>A </td> </tr>
<?php } while ($row_record = mysqli_fetch_assoc($query_record)); ?>
</table>
</div></body></html>
Now this is where i am stuck. How do i implement this. How do i return the dynamically generated code back to the
$pdf_content='
and make it work.
$pdf_content= include('page.pp'); //something like this doesn't seem to work
I welcome any alternative idea on the same

The main thing to note about your code changes is that the HTML is now outside of a code block. This means that PHP will send that code to the browser as it's processed. To get around this you would need to enable output buffering to capture the rendered text.
ob_start();
include('page.php');
$pdf_content = ob_get_clean();
ob_end_clean();
Note that some systems may limit the size of the output buffer (see the output_buffering setting). You can check that using ini_get('output_buffering');. If a limit is enabled make sure the size of your rendered HTML is less than the maximum size of the buffer.

Related

mb_convert_encoding(): Unable to detect character encoding in DOMPDF Laravel 5.5

I am using Laravel 5.5 for developing Application, For The Generation of PDF I am using laravel dompdf Package
Here is Link: https://github.com/barryvdh/laravel-dompdf
I was already Created issue on Github for this .
Here is My Laravel Code:
public function ViewPDF($id)
{
$product = Product::find($id);
$category = Category::find($product->category_id);
$product_line = ProductLine::find($product->product_line_id);
$template = View('product_and_category/PDF_Template', ['data'=>$product]);
return $this->GeneratePDF($template);
}
public function GeneratePDF($html) {
$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($html);
return $pdf->stream();
}
Here is HTML , I have Already Added the UTF-8 in My HTML, But still having the same issue its looking like bug in the package.
<!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" />
<title>Title</title>
</head>
<body style="margin:0px;">
<section style="width:100%; margin:0; text-align:center;">
<div style="background:url({{asset('/images/red-nav-bg.jpg') }}) repeat-x 0px 68px #702425;">
<img src="{{ asset('/images/logo.png') }}" width="auto" height="auto" alt="logo" />
</div>
</section> <!---**** Section Close ****--->
<div style="width:1100px; margin:30px auto; text-align:center;">
<img src="assets/images/doorImg2.jpg" width="auto" height="auto" alt="logo" style="padding: 30px 40px; border: 1px solid #cdced1;" />
</div>
<div style="width:1100px; margin:0 auto;">
<table width="100%" border="1" cellspacing="0" cellpadding="10" style="margin-bottom:30px; font-size:14px; border-color:#cdced1; font-family:sans-serif;">
<tr>
<td>Category</td>
<td>adsfdsaf</td>
</tr>
<tr>
<td>Product Line</td>
<td>Draft beer systems & refrugeration</td>
</tr>
<tr>
<td>Model #</td>
<td>D-36-18RL</td>
</tr>
<tr>
<td>Description</td>
<td>36" L x 18"D stainless steel sink</td>
</tr>
<tr>
<td>Cost</td>
<td>$</td>
</tr>
<tr>
<td>Number of Faucets</td>
<td>8</td>
</tr>
<tr>
<td>Material Finishes</td>
<td>QF_Metal - Mirror - Finished</td>
</tr>
<tr>
<td>Dimension</td>
<td>15 7/8</td>
</tr>
</table>
</div>
<div style="width:100%; margin:0 auto; background-color:#f9f9f9; text-align:center; padding:30px 0px; font-size:13px; color: #ccc; font-family:sans-serif;">
<p style="margin: 0px;">© 2017 Copyrights</p>
</div> <!---**** Footer Close ****--->
</body>
</html>
Some HTML Tags are not encoded in DOMPDF that's why i was facing this error
after some clean up in html template working fine
The reason you are recieving this error is because you have included a dollar sign $, it does not recognise the dollar sign remove it and you should be fine.

How to display a Japanese string inside HTML?

I am creating a PDF using DOMPDF. The pdf contains some images and strings. I am printing this values as php variables inside my HTML Layout and then converting HTML to PDF. Some of my strings are in Japanese. But it rendering in PDF as ????.
I used <meta http-equiv="Content-Type" content="text/html; charset=utf-8">. But nothing happends..
My code used is..
$bio_tbl = '<html style="margin:20px 20px 0px; padding:0;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="margin:0; padding:0;">
<table style="vertical-align: top;">
<tr>
<td style="vertical-align: top;padding-top:4px;">'.$model_first_img.'</td>
<td style="vertical-align:top;">
<table style="margin:0px 0px 5px 3px;">
<tr>
<td style="width:220px;vertical-align:top;">'.$model_second_img.'</td>
<td style="width:220px;vertical-align:top;">'.$model_third_img.'</td>
</tr>
</table>
<table style="margin:0px 0px 5px 3px;">
<tr>
<td style="width:220px;vertical-align:top;">'.$model_forth_img.'</td>
<td style="width:220px;vertical-align:top;">'.$model_fifth_img.'</td>
</tr>
</table>
<table style="margin:0px 0px 0px 3px;">
<tr>
<td style="width:220px;vertical-align:top;">'.$text.'</td>
<td style="width:220px;vertical-align:top;"><img style="width:210px;height:210px;" src="'.$black_image_path.'"></td>
</tr>
</table>
</td>
<td>
<img src="'.$copy_img.'">
</td>
</tr>
<tr>
<td style="vertical-align:top;text-align:center;font-size:20px;margin-top:5px"><b><u>BIO</u></b></td>
</tr>
<tr>
<td style="vertical-align:top;">
<div style="text-align:left;font-size:14px; margin-bottom:10px; margin-top:10px;">'.$bio_text.'</div>
</td>
</tr>
</table>
</body>
</html>';
Converting to PDF using following code..
$dompdf = new DOMPDF();
$dompdf->set_base_path($path);
$dompdf->load_html($bio_tbl);
$dompdf->set_paper("a3", "portrait");
$dompdf->render();
$pdf = $dompdf->output();
$filename = $pdfname;
$dir = DRUPAL_ROOT .'/sites/default/files/temp_pdf/bio_'.$filename;
file_put_contents($dir,$pdf);
All helps appreciated..
Try to use :
$dompdf->load_html($content, 'UTF-8');

PHP not passing SOME session variables to another script

I'm going nuts to try to understand why the script below (let's call it script1 is passing session variable $_SESSION['emptystcode'] to bulkstOLD.php but not the other two: $_SESSION['dlstrest'] and $_SESSION['dllist']. I have session_start(); on the first command line of the called script.
All this script1 does is to $_GET the Restaurant and List names and display a form where the user can fill in a CODE field and submit it.
To makes things worse, I've created another script (a simplified version of this caller script) which just set the session variables and calls the same bulkstOLD.php and it works ok. I wonder if this has something to do with the $_GET. Any help would be much appreciated.. Thanks!!
Here is the code:
<?php
session_start();
include ('logged.php');
require_once ('functions.php');
$acisversion = $_SESSION['acisversion'];
reset_all();
$cyear = date(Y);
$cmonth = date(M);
$cday = date(d);
$configs = include('config.php');
$_SESSION["module"] = 'st';
$_SESSION['favstlists_ref'] = 0;
$strest = $dlstrest = $_GET['dlstrest'];
$favstlist = $dllist = $_GET['dllist'];
$restname = 'restname_'.$strest;
$stlistrest = $configs[$restname];
?>
<!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=iso-8859-1"/>
<title>ACIS - Edit Lists</title>
<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="stmenu.js"></script>
<style type="text/css">
#import url(acis.css);
</style>
<script type="text/javascript" src="js.js"></script>
</head>
<body>
<div id="content">
<?php
$_SESSION['stcodesub'] = $stcodesub = $stcode = ($_POST["stcodein"]);
dbfile_init() ;
$_SESSION['stcode'] = $stcode;
if(isset($_POST["editSave"]))
{
connect_db ();
if (!empty($stcode))
{
check_code_for_st_list();
$emptystcode = 0;
}
else
{
$emptystcode = 1;
}
$_SESSION['dlstrest'] = $dlstrest;
$_SESSION['dllist'] = $dllist;
$_SESSION['emptystcode'] = $emptystcode;
if ((!$emptystcode and $codestok) or $emptystcode)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=bulkstOLD.php">';
exit;
}
}
?>
<table width="100%" border="0" align="center">
<tr>
<td width="223" align="left"></td>
<td width="111" align="right"></td>
</tr>
</table>
</style>
<form method="post" id="editLists" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<table width="739" border="0" align="center" cellspacing="0" bgcolor="#171717">
<tr>
<td colspan="3"
style="color:#00CC00;
text-align: left;
padding: 0;
background: #2e2e2e url(images/nav_bar.jpg) repeat-x;
font-size: 0.9em;
color: white;
height:16px;"><script type="text/javascript" src="mainmenu.js"></script></td>
</tr>
<tr>
<td width="502"><h2 style="color:red;"> Atualizar Listas Favoritas de Pratos</h2></style></td>
<td width="231" colspan="2" align="right"><?php echo $configs[footer];?></td>
</tr>
<tr>
<td colspan="3" align="right" ><table width="100%" border="0" align="center">
<tr>
<td align="center">Restaurante:</td>
<td width="84" align="center" valign="bottom">Adicionar Código</td>
<td width="350" align="center">Lista a ser atualizada:</td>
<td width="150" align="left" valign="bottom"><span class="error"><?php echo $favErr;?></span></td>
</tr>
<tr>
<td width="135" align="center"><b><?php echo $stlistrest; ?></b></td>
<td align="center">
<?php
echo $stcodeline;
?>
</td>
<td align="center"><b><?php echo $dllist; ?></b></td>
<td align="right"><input type="submit" name="editSave" style="background-color: #009900; color: #FFFFFF;" value="Submeter" /></td>
</tr>
</table></td>
</tr>
</table>
</form>
<?php
$_SESSION["module"] = 'st';
?>
</div>
</body>
</html>
The only possible explanation for your problem is that you might have not written <?php session_start();?> in the very beginning, before any HTML tags(even doctype). Write it on top of every relevant php document.
Look if all your files are saved as UTF-8 without BOM, not just UTF-8.
This BOM dissables sessions.
And look if all your files are called as they are in the same subdomain.
www.domain.com/file1.php,
ww2.domain.com/file2.php,
domain.com/file3.php
... with diferent subdomains should not work.

reload the page using ajax in order to create a live chat

I have this code:
<?php require_once("config.inc.php"); ?>
<?
ob_start();
session_start();
if(isset($_SESSION['myusername'])) {
// do nothing here
} else { ?>
<!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" />
<title>Live chat</title>
</head>
<body bgcolor="#000000">
<font color="white" size="+3"><b>You are not logged in! <br />
Log in and start chatting!</b></font>
</body>
</html>
<?php exit(); }
ob_flush();
?>
<!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" />
<meta name="description" content="<?php echo $meta_description ?>" />
<meta name="keywords" content="<?php echo $meta_keywords ?>" />
<title><?php echo $site_name; ?> | Live chat</title>
<link rel="icon" type="image/gif" href="favicon.png" >
<link href="style.css" rel="stylesheet" type="text/css" />
<style>
body { margin:0;padding:0; background-image:url(images/background.jpg); }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
$("#lolmesazhet").load("mesazhetnechat.php");
var refreshId = setInterval(function() {
$("#lolmesazhet").load("mesazhetnechat.php");
}, 1000);
$.ajaxSetup({ cache: false });
});
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="500px" bgcolor="#000000" >
<?php include 'headerchat.inc.php'; ?>
</td>
</tr>
<tr>
<td width="500px" align="left" valign="top" style="padding:20px 5px 20px;">
<?php
if($_POST['submit654']) {
$result128 = mysqli_query($con,"SELECT id FROM users WHERE email = '$_SESSION[myusername]'");
$row128 = mysqli_fetch_array($result128);
date_default_timezone_set("Europe/Tirane");
$todaydate3 = date("Y-m-d H:i:s");
mysqli_query($con,"INSERT INTO chat (id, derguesi, dhoma, mesazhi, ora) VALUES (NULL, '$row128[id]', 'Main room', '$_POST[mesazhi]', '$todaydate3')");
}
?>
<table width="470px" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="50px" valign="middle" colspan="2" style="border-bottom:1px solid #FFFFFF;"> </td>
</tr>
<tr>
<td width="320" height="339px" valign="top" style="padding:3px;">
<div style="width:320px; height:339px; overflow-y:auto;">
<?php
$result73 = mysqli_query($con,"SELECT * FROM chat WHERE dhoma = 'Main room' ORDER BY id DESC");
while($row73 = mysqli_fetch_array($result73))
{
$result127 = mysqli_query($con,"SELECT username FROM users WHERE id = '$row73[derguesi]'");
$row127 = mysqli_fetch_array($result127);
?>
<table width="320px" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150" align="left"><font color="white" size="4"><b><?php echo $row127['username']; ?></b></font></td>
<td width="170" align="right"><?php echo $row73['ora']; ?></td>
</tr>
<tr>
<td colspan="2">
<font color="white"><?php echo $row73['mesazhi']; ?></font>
</td>
</tr>
</table>
<?php } ?>
</div>
</td>
<td width="150" height="450px" rowspan="2" valign="top" style=" padding:3px; border-left:1px solid #FFFFFF;">
<div style="width:150px; height:450px; overflow-y:auto;">
<font color="#FFFFFF" size="+2"><b>Online users:</b></font><br /><br />
<?php
$result = mysqli_query($con,"SELECT username FROM users WHERE verifikuar='po' AND online = 'po'");
while($row = mysqli_fetch_array($result))
{ ?>
<font color="#FFFFFF"><b><?php echo $row['username']; ?></b></font> <br />
<?php }
?>
</div>
</td>
</tr>
<tr>
<td height="50px" valign="middle" style="border-top:1px solid #FFFFFF; padding:3px; border-right:1px solid #FFFFFF;">
<form action="" method="post" name="comesazh">
<textarea name="mesazhi" cols="35" rows="4" required="required"></textarea>
<br /><input type="submit" name="submit654" id="submit654" value="Send" style="border-radius:0px; border-size:1px; border-style:solid; border-color:#ffffff; border-width:thin; background-color:#000000; color:#ffffff; height:26px; width:60px; font-size:16px;" />
</form>
</td></tr>
</table>
</body>
</html>
I would like to know if it is possible to reload that page using ajax in order to create a live chat and if yes, how to do it.
I tried many ways like reloading just a part of it using $.load function but it does not work. Then I tried to $.load all the page, but still did not work. After a lot of silly efforts, I gave up.
Here is what you can do to have the chat box update without reloading the page.
Chat page that you have:
<script>
window.setInterval(function(){
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","response.php",true);
xmlhttp.send();
}, 5000);
</script>
<div id="myDiv"><h2>This should be your chat box</h2></div>
Response.php
<?php
//do the while loop for the amount of chat you want to see
//example
for ($i = 1; $i <= 10; $i++) {
echo $i.'<br/>'; // Print out $i
}
?>
This will update the chat box every 5 seconds with the most recent chats. Give it a shot
If no element is matched by the selector — in this case, if the document does not contain an element with id="result" — the Ajax request will not be sent.
From jQuery.load manual. I can't see element with ID "lolmesazhet" in your code. Or I'm missing something.

iframe doesn't work in PHP? [duplicate]

This question already has an answer here:
Echo inside an element attribute?
(1 answer)
Closed 10 years ago.
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><img style=" margin:5px; border:#ccc 1px solid" src="inventory_images/' . $id . '.jpg" width="150" height="160"/></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><img style=" margin:5px; border:#ccc 1px solid" src="inventory_images/' . $id . '.jpg" width="150" height="160"/></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"> Search By Clothing | Search By Retailers</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.
Th
Just loose the iFrame and echo the $dyn_table inside the table you already have?
Your are not aware of what an iframe means, maybe :
<!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"> Search By Clothing | Search By Retailers</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> </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><img style=" margin:5px; border:#ccc 1px solid" src="inventory_images/' . $id . '.jpg" width="150" height="160"/></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><img style=" margin:5px; border:#ccc 1px solid" src="inventory_images/' . $id . '.jpg" width="150" height="160"/></div></div></td>';
}
$i++;
}
$dyn_table .= '</tr></table>';
echo $dyn_table;
?>
An iframe it's a totally different page, so you should use 2 pages....just like a propose, one for the html and one for the iframe....i hope it helps.
PS: I change the a href ;)
Saludos ;)

Categories