Include my html code inside content of email in sendgrid emai - php

I have made separate html file and using file_get_content i am using it to include it in my content part but when i recieve email html code is displayed as a text rather than what the ouptut of html file should be
<html>
<head>
</head>
<body>
<div>
<div class="popup-logo" style="width: 100px;">
<img src="logo.png" alt="jk" style="margin-left: 45%;width: 200px;height: 50px;"></div>
</div>
<div id="popup" style="width: 100%;margin-left: auto;margin-right: auto;background: #FFFFFF;-moz-box-shadow: #64686e 0px 0px 3px 3px;-webkit-box-shadow: #64686e 0px 0px 3px 3px;margin-top: 1%;">
<div class="search-col" style="border-bottom: 1px solid #e5e5e5;float: left;margin-bottom: 5px;padding: .2px;width: 100%;table, th, td {
border: .5px solid silver;border-collapse: collapse;">
<div class="select-style">
<div class="select-style-text" style="width: 100%;height: 67px;float: left;padding-left: 10px;">
<p style="color: #840107;font-family: Hind;font-size: 25px;font-weight: 600;text-align: left;margin-left: 40%;text-overflow: none;text-indent: 2em;">Dispatched Details</p>
</div>
<div class="da" style="color:green;margin-left:85%;">
<?php
$date = date('d-M-Y H:i:s');
echo "Date"." ". $date;
?>
</div>
</div>
</div>
<div>
<div id="wer">
<h3 style="padding: 0.5px;padding-left: 5px;">Order Number:<?php echo $_SESSION['id'];?></h3>
<h3 style="padding: 0.5px;padding-left: 5px;">Vendor details:</h3>
<div id="wer" style="margin-left:0%;">
<table style="width: 100%;border: 1px solid silver;border-collapse: collapse;text-align: center;">
<tr>
<th style="border: 1px solid silver;border-collapse: collapse;text-align: center;">VendorName</th>
<th style="border: 1px solid silver;border-collapse: collapse;text-align: center;">Code</th>
<th style="border: 1px solid silver;border-collapse: collapse;text-align: center;">Email</th>
<th style="border: 1px solid silver;border-collapse: collapse;text-align: center;">Contact</th>
</tr>
<tr>
<td style="border: 1px solid silver;border-collapse: collapse;text-align: center;"><?php echo $_SESSION['vnm']?></td>
<td style="border: 1px solid silver;border-collapse: collapse;text-align: center;"><?php echo $_SESSION['vcd']?></td>
<td style="border: 1px solid silver;border-collapse: collapse;text-align: center;"><?php echo $_SESSION['vem']?></td>
<td style="border: 1px solid silver;border-collapse: collapse;text-align: center;"><?php echo $_SESSION['vcn']?></td>
</tr>
</table>
</div>
<div id="wer" style="margin-top:3%;">
<h3 style="padding: 0.5px;padding-left: 5px;">Other Details:</h3>
<style>
</style>
<table style="width: 100%;border: 1px solid silver;border-collapse: collapse;text-align: center;">
<tr>
<th style="border: 1px solid silver;border-collapse: collapse;text-align: center;">Driver name</th>
<th style="border: 1px solid silver;border-collapse: collapse;text-align: center;">Driver contact </th>
<th style="border: 1px solid silver;border-collapse: collapse;text-align: center;">Vehicle Number</th>
</tr>
<tr>
<td style="border: 1px solid silver;border-collapse: collapse;text-align: center;"><?php echo $_SESSION['drivname']?></td>
<td style="border: 1px solid silver;border-collapse: collapse;text-align: center;"><?php echo $_SESSION['dcontact']?></td>
<td style="border: 1px solid silver;border-collapse: collapse;text-align: center;"><?php echo $_SESSION['vnumber']?></td>
</tr>
</table>
</div>
<?php session_destroy();?>
</div></div></div></body>
</html>
<?php
require '/sendgrid-php/vendor/autoload.php';
if(require("sendgrid-php/vendor/autoload.php"))
{echo "path found";}
$from = new SendGrid\Email(null, 'k1#gmail.com');
$subject ='Order number is';
$to = new SendGrid\Email(null, 'k2#gmail.com');
$r=file_get_contents('ret.html');
$content = new SendGrid\Content("text/plain",$r);
$mail = new SendGrid\Mail($from, $subject, $to, $content);
$apiKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$sg = new \SendGrid($apiKey);
$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode();
echo $response->headers();
echo $response->body();
?>

You have to include that file, evaluate it as PHP and capture it inside a variable instead of storing the unevaluated content in a string:
ob_start();
include("ret.html");
$r = ob_get_clean();
$content = new SendGrid\Content("text/html",$r);
By the way, you should consider using a templating engine for that job.

From what I can understand, your email is sent as plain text instead of an html. That's because you have the email type set as text/plain when creating the SendGrid object. Changing it to text/html should do it. Replace this line
$content = new SendGrid\Content("text/plain",$r);
with
$content = new SendGrid\Content("text/html",$r);

Related

How to remove extra borders in continues pages of HTML table in mpdf?

<div id="page-details">
<table style="page-break-inside: avoid !important;" width="1280px" cellspacing="0" cellpadding="0">
<tr style="page-break-inside: avoid !important; ">
<td width="1280px">
<table autosize="1" cellspacing="0" cellpadding="0" width="1280px">
<tr>
<td style="border-right:1px solid; height:25px; text-align:center;" width="40px">No</td>
<td width="320px" style="border-right:1px solid; text-align:center; height:25px;">Typology</td>
<td width="415px" style="border-right:1px solid; text-align:center; height:25px;">Description of Goods</td>
<td width="100px" style="border-right:1px solid; text-align:center; height:25px;">Width</td>
<td width="100px" style="border-right:1px solid; text-align:center; height:25px;">Height</td>
<td width="80px" style="border-right:1px solid; text-align:center; height:25px;">Qty</td>
<td width="100px" style="border-right:1px solid; text-align:center; height:40px;">Sq Feet
</td>
<td width="125px" style="text-align:center; height:40px;">Total
</td>
</tr>
</table>
</td>
</tr>
<!-- for loop start -->
<?php
if($quotation->items != null && count($quotation->items) > 0) {
$index = 1;
for ($i=0; $i < count($quotation->items); $i++) {
?>
<tr style="page-break-inside: avoid !important;">
<td width="1280px">
<table cellspacing="0" cellpadding="0" width="1280px" style="overflow-wrap: break-word; page-break-inside: avoid !important; ">
<tr>
<td style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; height:75px; text-align:center;" width="40px">
<?php echo $index++; ?>
</td>
<td width="320px" style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; height:275px;">
<?php
if ($quotation->items[$i]->seriesType == 7 ||
$quotation->items[$i]->seriesType == 8) {
?>
<img src="<?php echo $quotation->items[$i]->url;?>" style="max-height: 320px; max-width: 275px; padding: 5px;">
<?php
} else {
?>
<img src="<?php echo $quotation->items[$i]->url;?>" style="max-height: 320px; max-width: 275px; padding: 5px;">
<?php
}
?>
</td>
<td width="415px" style="word-wrap: break-word; border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; overflow-wrap: break-word; padding: 5px;">
<?php
echo "Pattern: <b>" . $quotation->items[$i]->patternName . "</b>";
?>
<br>
<p style="font-size: 20px;">
<?php
echo "Series: <b>" . $quotation->items[$i]->seriesName . "</b>";
?>
<br>
<?php
echo "Section Company: <b>" . $quotation->items[$i]->companyName . "</b>";
?>
<br>
<?php
echo "Glass: <b>" . $quotation->items[$i]->type . "</b>";
?>
<br>
<?php
echo "Color: <b>" . $quotation->items[$i]->colorType . "</b>";
?>
</p>
<br>
<?php
if (isset($quotation->items[$i]->location)) {
?>
<p style="font-size: 20px; font-weight: bold;">
<?php
echo "Location: " . $quotation->items[$i]->location;
?>
</p>
<?php
}
?>
<br>
<p style="font-size: 20px;">
<?php
if ($quotation->items[$i]->lockId > 0) {
echo "Lock - <b>" . $quotation->items[$i]->lockName . "</b>";
?>
</p>
<?php
}
?>
<?php
if (!empty($quotation->items[$i]->lockDescription)) {
?>
<p style="font-size: 20px; margin-left: 20px;">
<?php
echo "Description - <b>" . $quotation->items[$i]->lockDescription . "</b>";
?>
</p>
<?php
}
?>
<?php
if (!empty($quotation->items[$i]->make)) {
?>
<p style="font-size: 20px; margin-left: 20px;">
<?php
echo "Make - <b>" . $quotation->items[$i]->make . "</b>";
?>
</p>
<?php
}
?>
<?php
if (!empty($quotation->items[$i]->model)) {
?>
<p style="font-size: 20px; margin-left: 20px;">
<?php
echo "Model - <b>" . $quotation->items[$i]->model . "</b>";
?>
</p>
<?php
}
?>
<?php
if (!empty($quotation->items[$i]->brand)) {
?>
<p style="font-size: 20px; margin-left: 20px;">
<?php
echo "Brand - <b>" . $quotation->items[$i]->brand . "</b>";
?>
</p>
<br>
<?php
}
?>
</td>
<td width="100px" style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; text-align:center; height:75px;">
<?php echo number_format($quotation->items[$i]->totalWidth, 2); ?>
</td>
<td width="100px" style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; text-align:center; height:75px;">
<?php echo number_format($quotation->items[$i]->totalHeight, 2); ?>
</td>
<td width="80px" style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; text-align:center; height:75px;">
<?php echo $quotation->items[$i]->qty; ?>
</td>
<td width="100px" style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; text-align:center; height:75px;">
<?php
$totalSqFeet = $quotation->items[$i]->totalFoot * $quotation->items[$i]->qty;
echo number_format($totalSqFeet, 2);
?>
</td>
<td width="125px" style="border-top:1px solid; border-bottom: 1px solid;text-align:center; height:75px;">
<?php echo number_format($quotation->items[$i]->total, 2); ?>
</td>
</tr>
</table>
</td>
</tr>
<?php
}
}
?>
<!-- for loop end -->
</table>
</div>
Following is the Image of the issue I am facing in PDF for the reference.
I have placed page-break-inside: avoid !important; code inside table and tr both.
Also set $mpdf->shrink_tables_to_fit = 1; in MPDF object but still I am getting extra borders.

Html sent using the php function called mail() is not display as expected when received

I have this php script that generates html tables and sends them via mail() function.
here is a sample of the generated html code :
<table style="border-collapse: collapse;">
<tbody>
<tr>
<td style="border: 1px solid black;"><b>Dates</b></td>
<td style="border: 1px solid black;"><b>05/07</b></td>
<td style="border: 1px solid black;"><b>06/07</b></td>
<td style="border: 1px solid black;"><b>07/07</b></td>
<td style="border: 1px solid black;"><b>08/07</b></td>
<td style="border: 1px solid black;"><b>09/07</b></td>
<td style="border: 1px solid black;"><b>10/07</b></td>
<td style="border: 1px solid black;"><b>11/07</b></td>
</tr>
<tr">
<td style="border: 1px solid black;">Pointage personnel</td>
<td style="border: 1px solid black;">35</td>
<td style="border: 1px solid black;">38</td>
<td style="border: 1px solid black;">38</td>
<td style="border: 1px solid black;">38</td>
<td style="border: 1px solid black;">38</td>
<td style="border: 1px solid black; background-color:Tomato;">0</td>
<td style="border: 1px solid black; background-color:Tomato;">0</td>
</tr>
...
</tbody></table>
Here is the php code for sending the email :
/// Sending emails
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/HTML; charset=utf-8' . "\r\n"; // or utf-8
$headers .= 'Content-Transfer-Encoding: 8bit'. "\r\n";
$headers .= 'From: ABC <abc#redacted.com>' . "\r\n";
$listEmails = [
"redacted#gmail.com",
"redacted#outlook.com",
];
foreach ($listEmails as $email){
mail($email,"# REPORTING #",nl2br($html),$headers);
}
Here is how the genereted html is displayed on the browser when i use echo (before sending the email) :
Here is how it is displayed on Outlook or gmail after being sent via mail() function:
I tried "inspect element" on gmail side here is the html code that i got :
<table style="border-collapse:collapse;border:none" cellspacing="0" cellpadding="0" border="1">
<tbody>
<tr>
<td style="border:solid black 1.0pt;padding:3.0pt 3.0pt 3.0pt 3.0pt">
<p class="MsoNormal">
<b>Dates</b><u></u><u></u>
</p>
</td>
<td style="border:solid black 1.0pt;border-left:none;padding:3.0pt 3.0pt 3.0pt 3.0pt">
<p class="MsoNormal">
<b>05/07</b><u></u><u></u>
</p>
</td>
<td style="border:solid black 1.0pt;border-left:none;padding:3.0pt 3.0pt 3.0pt 3.0pt">
<p class="MsoNormal" >
< td style="border: 1px solid black; border-collapse: collapse; padding: 4px; text-align: center;"><b>06/07</b><u></u><u></u>
</p>
<p class="MsoNormal">
<b>07/07</b><u></u><u></u>
</p>
</td>
<td style="border:solid black 1.0pt;border-left:none;padding:3.0pt 3.0pt 3.0pt 3.0pt">
<p class="MsoNormal">
<b>08/07</b><u></u><u></u>
</p>
</td>
<td style="border:solid black 1.0pt;border-left:none;padding:3.0pt 3.0pt 3.0pt 3.0pt">
<p class="MsoNormal">
<b>09/07</b><u></u><u></u>
</p>
</td>
<td style="border:solid black 1.0pt;border-left:none;padding:3.0pt 3.0pt 3.0pt 3.0pt">
<p class="MsoNormal">
<b>10/07</b><u></u><u></u>
</p>
</td>
<td style="border:solid black 1.0pt;border-left:none;padding:3.0pt 3.0pt 3.0pt 3.0pt">
<p class="MsoNormal">
<b>11/07</b><u></u><u></u>
</p>
</td>
</tr>
<tr>
<td style="border:solid black 1.0pt;border-top:none;padding:3.0pt 3.0pt 3.0pt 3.0pt">
<p class="MsoNormal">
Pointage personnel<u></u><u></u>
</p>
</td>
...
</tr>
...
</tbody></table>
The issue comes from using shorthand css properties while styling the HTML.
In my case i was using :
<td style = "border: 1px solid black;"> cellText </td>
I should write my inline css like this inst
<td style = "border-width: 1px ; border-style: solid; border-color: black;">
cellText
</td>
I Have made this change in my code and tested it and the issue was gone.

Why this code places the - sign at the last

I am using below code to display advanced custom field (date fields) in wordpress. I want two dates to appear like e.g 12 mar - 15 mar 2017.
I am using this code
<?php echo the_sub_field('start_date').' - '.the_sub_field('end_date'); ?>
How to do it please explain ?
Right now I am getting result like this 18/09/201722/09/2017 -
my full html code
<table style=" border-collapse: collapse; table-layout: fixed; width: 800px;">
<tbody>
<tr>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">Refernce</h5></td>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">Dates</h5></td>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">Venue</h5></td>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">Fees</h5></td>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">CPE Credits</h5></td>
<td style="border: 1px solid #ddd;"><h5 style="color:#044970;">Regsitrations</h5></td>
</tr>
</tbody>
</table>
<table style=" border-collapse: collapse; table-layout: fixed; width: 800px;">
<tbody>
<?php
if( have_rows('sub_seminars') ):
while( have_rows('sub_seminars') ) : the_row();
?>
<tr>
<td style="border: 1px solid #ddd;"><h6><?php the_sub_field('ref'); ?></h6></td>
<td style="border: 1px solid #ddd;"><h6><?php echo the_sub_field('start_date').' - '.the_sub_field('end_date'); ?></h6></td>
<td style="border: 1px solid #ddd;"><h6><?php the_sub_field('venue'); ?></h6></td>
<td style="border: 1px solid #ddd;"><h6><?php the_sub_field('fees'); ?></h6></td>
<td style="border: 1px solid #ddd;"><h6><?php the_sub_field('cpe_credits'); ?></h6></td>
<td style="border: 1px solid #ddd;"><a href="<?php home_url(); ?>/euromatechnew/seminar-registrations?seminartitle=<?php echo htmlentities(urlencode(get_the_title())) ?>&seminarvenue=<?php echo the_sub_field('venue');
?>&seminardates=<?php echo the_sub_field('start_date').the_sub_field('end_date'); ?>&seminarref=<?php echo the_sub_field('ref') ?>" class="dt-btn" style="margin: 3px 0px 0px 0px">Register Now</a></td>
</tr>
<?php
endwhile;
endif;
?>
</tbody>
</table>
the_sub_field function already echoes data.
To get data and then echo it - use get_sub_field.
Proper code is:
<?php echo get_sub_field('start_date').' - '.get_sub_field('end_date'); ?>
Or as with your markup:
<td style="border: 1px solid #ddd;"><h6><?php the_sub_field('start_date');?> - <?php the_sub_field('end_date');?></h6></td>
To format your dates as you need you can use date fomatting functions of php, e.g date.

DOMPdf with php script content

I need to generate pdf using dom pdf and php.
I tried this but I get error 500, I have no syntax errors. If I try : $html='Title here' it works. I tried using an external php script and by using file_get_contents() function but it didn' work. Anybody can help me find a solution to generate the pdf using a php script?
This is my script (dompdf/index.php):
<?php
include("dompdf_config.inc.php");
include "../config.php";
include("../db/mysql.php");
$pers=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$inv=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$cli=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$proj=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$total=$db->sql_query('//-----query here--------');
$ret.=
'
<html>
<head>
</head>
<body>
<div id="left" style="float:left; margin:0 auto;width400px;">
<strong><h2></h2></strong>
</div>
<div id="left" style="float:left; margin:0 auto; width:300px; ">
<h2 style="">INVOICE</h2>
<table style="border-style : solid;
border-width:2 px;
border-color : black; width:300px; ">
<tr style="border-bottom: 2px solid black !important;"><th style="border-bottom: 2px solid black !important;">Invoice Date</th><th style="border-bottom: 2px solid black !important;">Invoice No.</th></tr>
<tr><td align="center">'.$inv["date_due"].'</td><td align="center">'.$inv["invoice_no"].'</td></tr>
</table>
</div>
<br />
<div style="float:left; margin:0 auto;width:100%;margin-top:50px; width=300px;">
<table style="border-style : solid; border-width:2 px; border-color : black; width=400px;">
<tr border="1"><th style="border-bottom: 2px solid black !important;" width="400">INVOICE TO:'.$pers['name'].'</th></tr>
<tr><td width="400">
'.$cli["name"].'<br />
'.$cli["street"].'<br />
'.$cli["city"].'<br /><br />
'.$cli["country"].'<br />
</td></tr>
</table>
</div>
<br />
<div style="float:left; width:600; margin-top:50px;margin-bottom:50px;">
<table style="border-style : solid; border-width:2 px; border-color : black; width=600px;">
<tr width=800px; border="2" style="bordder-bottom: #000 solid;"><th colspan="2" style="border-bottom: 2px solid black !important;width:600px;">INVOICE DESCRIPTION</th></tr>
<tr ><td align="right" width="300"><strong>Project name:</strong></td>
<td>'.$proj["name"].'</td></tr>
<tr><td align="right" width="300"><strong>Job number:</strong></td>
<td width="300">'.$proj["job_no"].'</td></tr>
<tr><td align="right" width="300"><strong>Job reference:</strong></td>
<td width="300"> '.$proj["job_reference"].'</td></tr>
<tr><td align="right" width="300"><strong>Source Language:</strong></td>
<td width="300">'.$proj["source_lang"].'</td></tr>
<tr><td align="right" width="300"><strong>Target Language:</strong></td>
<td width="300">'.$proj["targ_lang"].'</td></tr>
<tr><td align="right" width="300"><strong>Deadline:</strong></td>
<td width="300">'.$proj["deadline"].'</td></tr>
</table>
</div>
<br />
<br />
<div style="margin-top:50px;width:600px;">
<table style="border-style : solid; border-width:2 px; border-color : black; width:600px;">
<tr border="1" style="border-bottom: black solid"><th style="border-bottom: 2px solid black !important;">Task description</th><th style="border-bottom: 2px solid black !important;">Unit</th><th style="border-bottom: 2px solid black !important;">Qty</th><th style="border-bottom: 2px solid black !important;">Fee Unit</th><th style="border-bottom: 2px solid black !important;">Amount</th></tr>';
$ret1="";
$sum=0;
while($r=$db->sql_fetchrow($total)){
$task_type=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$quote_type=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$unit=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$t_lang=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$s_lang=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$price=$db->sql_fetchrow($db->sql_query('//-----query here--------'));
$amount=$price["unit_fee"]*$r["unit_qty"];
$sum+=$amount;
$ret.='
<tr style="alignment-adjust: central;"><td>'.$task_type["task"].' '.$quote_type["client_quote"].'</td><td>'.$unit["name"].'</td><td>'.$r["unit_qty"].'</td><td>'.$price["unit_fee"].'</td><td align="right">'.$amount.' '.$r["currency"].'</td></tr>
';
$curr=$r["currency"];
$ret.= '<tr ><td colspan="4" align="right">Subtotal</td><td colspan="4" align="right">'.$sum.' '.$curr.'</td></tr>
<tr ><td colspan="4" align="right">100% due on'.$r["date_due"].'</td><td colspan="4" align="right">'.$sum.' '.$curr.'</td></tr>
<tr ><td colspan="4" align="right">VAT 0%</td><td colspan="4" align="right">0,0 '.$curr.'</td></tr>
<tr ><td colspan="4" align="right"><strong>TOTAL</strong></td><td colspan="4" align="right"><strong>'.$sum.' '.$curr.'</strong></td></tr>
</tr>
</table>
</div>
<br />
</table><br />
</div>
</body>
</html>';
$dompdf = new DOMPDF();
$dompdf->load_html($ret);
$dompdf->render();
$dompdf->stream("Invoice.pdf");
?>
Your content() function echoes the text. It pushes it to the screen, while you want to catch it in $html.
Use return instead.
UPDATE
In order to catch all query results to one return, you could append them to a variable like this:
function content() {
// Define the output variable
$output = "";
//Run query
$pers=$db->sql_fetchrow($db->sql_query('select * from clients_persons where person_id='.$_GET["ps"].''));
//Combine query results and html
$output .= $pers['name'];
$output .= " <i>";
$output .= $pers['email'];
$output .= " </i>";
return $output;
}
Check memory limit for such issues as well.

Get Data From a Table Created by Equi Join Query

i have a table created by my sql equijoin
and i want to retrieve data from that table by am getting error
the error is
dname.resource doesn't exist
and the code is
<style type="text/css">
a
{
text-decoration:none;
}
.Menu
{
width:150px;
float:left;
}
.fr
{
width:800px;
height:800px;
float:right
}
</style>
<div class="Menu">
<?php
mysql_connect("localhost","dbname","password");
mysql_select_db("dbanme");
$sql="select * from NSEIndices_latest";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
$tpnt=$row['TickerPlantCode']; //nse indice code
$indexname=$row['IndexName']; //nse indice index name
?>
<tr>
<td><?php echo $indexname;?><br></td>
</tr>
<?php }?>
</div>
<div class="fr">
<iframe height="780" width="780" scrolling="no" name="fr"></iframe>
</div>
the gtnsegainer.php page on am getting error is
the gtnsegainer page is in iframe
this page retrieve data from database according to the link on the above page
<table class="table" cellspacing="0" width="100%">
<tr>
<td align="left" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9;">Company Name
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">High
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Low
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Last Price
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Prv Close
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">Change
</th>
<td align="center" valign="middle" style="border:#e7e7e7 1px solid; background-color:#f9f9f9; background-color:#f9f9f9;">%Gain
</th>
</tr>
<?php
mysql_connect("localhost","dbname","password");
mysql_select_db("dbname");
$tpnt=$_GET['tpnt'];
$indexname=$_GET['indexname'];
$query="SELECT nsepricequotes_latest.Symbol, nsepricequotes_latest.CompanyName, nsepricequotes_latest.HighPrice, nsepricequotes_latest.LowPrice, nsepricequotes_latest.LastTradedPrice, nsepricequotes_latest.ClosePrice, nsepricequotes_latest.NetChange, nsepricequotes_latest.PercentChange, nse_index_constituents.Tickerplant_index_code
FROM nsepricequotes_latest, nse_index_constituents
WHERE nsepricequotes_latest.TickerPlantCode = nse_index_constituents.TickerPlant_scrip
AND PercentChange >0
ORDER BY PercentChange DESC ";
$result=mysql_query($query);
$query1="Select * from $result where NSE_Index_Name=$indexname";
$result1=mysql_query($query1);
while($row=mysql_fetch_array($result1))
{
$symbol=$row['Symbol'];
$CompanyName=$row['CompanyName'];
$HighPrice=$row['HighPrice'];
$LowPrice=$row['LowPrice'];
$previousclose=$row['LastTradedPrice'];
$ClosePrice=$row['ClosePrice'];
$netChange=$row['NetChange'];
$percentagechange=$row['PercentChange'];
?>
<tr>
<td align="left" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $CompanyName;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $HighPrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $LowPrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $previousclose; ?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $ClosePrice;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $netChange;?></td>
<td align="center" valign="middle" style="border-right:#e7e7e7 1px solid; border-left:#e7e7e7 1px solid ;border-bottom:#e7e7e7 1px solid;"><?php echo $percentagechange;?></td>
</tr>
<?php } ?>
</table>
it is hard to tell what your error is, in your particular setup, but i recommend adding some simple debugging as such, after each mysql_query($query); add if(mysql_error())die(mysql_error()); and that will point you in the right direction.

Categories