I have some link which show data on iframe with the help of temporary data from database
I am fetching this data with the help of query strings
The page with Links 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("dbname");
$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>
Now the link from above page fetch data with the help of query string at this page a temporary table is created by collectiong data from various tables
but am getting error while retrieve data from that temporary table
the page with temporary table is
<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'];
echo "1".$indexname. "<br>";
$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,nse_index_constituents.NSE_Index_Name
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);
echo "2".$indexname. "<br>";
while($row1=mysql_fetch_array($result))
{
$Symbol1=$row1['Symbol'];
$CompanyName1=$row1['CompanyName'];
$HighPrice1=$row1['HighPrice'];
$LowPrice1=$row1['LowPrice'];
$LastTradedPrice1=$row1['LastTradedPrice'];
$ClosePrice1=$row1['ClosePrice'];
$NetChange1=$row1['NetChange'];
$PercentChange1=$row1['PercentChange'];
$Tickerplant_index_code1=$row1['Tockerplant_index_code1'];
$NSE_Index_Name1=$row1['NSE_Index_Name'];
}
echo "3".$indexname. "<br>";
$tbl="create TEMPORARY TABLE temppice(Symbol varchar(100),CompanyName varchar(200),HighPrice float(50),LowPrice float(50),LastTradedPrice float(50),ClosePrice float(50),NetChange float(50),PercentChange float(50),Tickerplant_index_code varchar(100),NSe_Index_Name varchar(100))";
$res=mysql_query($tbl);
if (!$res) { die('Temporary table creation failed: ' . mysql_error()); }
if(mysql_error())die(mysql_error());
$intbl="Insert into temppice values('$Symbol1','$CompanyName1','$HighPrice1','$LowPrice1','$LastTradedPrice','$ClosePrice1','$NetChange1','$PercentChange1','$Tockerplant_index_code1','$NSE_Index_Name1')";
mysql_query($intbl);
if(mysql_error())die(mysql_error());
echo "4".$indexname. "<br>";
$query1="Select * from temppice where NSE_Index_Name=$indexname";
$result1=mysql_query($query1);
//if(mysql_error())die(mysql_error());
while($row=mysql_fetch_array($result1, MYSQL_BOTH))
{
$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>
the error am getting is
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mastertr/public_html/master/wpfiles/gtnsegainers.php on line 58
TEMPORARY tables have lifetime of one connection, so if you create the table during one request from the browser, and then want to fetch data from it in another request.... it's no longer there. The table does not exist and your query fails with no such table in database error.
Related
Can someone or somebody help me with my code or with my SQL execution? I'd like to create an excel file based on a specific group of data based on the event/activity they participated in.
Here is my code:
$program_admin = $_SESSION['username'];
$actvty_ID = $_POST['id'];
//$activitydate = $_POST['activity_date'];
if(isset($_POST['export_in_excel'])) {
$excel_sql = "SELECT *
FROM projectcode pj
INNER JOIN activities ac ON ac.projects_id = pj.projects_id
INNER JOIN participants re ON re.act_id = ac.id
WHERE pj.project_code='$program_admin'
ORDER BY re.id DESC "; //pj.project_code='$program_admin'
$excel_result = mysqli_query($connect, $excel_sql);
if(mysqli_num_rows($excel_result) > 0) {
$excel_output .='
<table class="excel_table" style="font-family:Calibri; border:1px solid #1f004d;">
<tr><td></td></tr>
<tr>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d;">No.</th>
<th colspan="2" style="text-align:center; font-weight:bold; border:1px solid #1f004d;">Name</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Age</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Gender</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">City/Municipality</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Province</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Contact No.</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Email Address</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Organization</th>
<th style="text-align:center; font-weight:bold; border:1px solid #1f004d; ">Signature</th>
</tr>
';
$no = 1;
while($excel_row = mysqli_fetch_array($excel_result)) {
$excel_output .='
<tr>
<td style="text-align:center;">'.$no.'</td>
<td>'.$excel_row["firstname"].'</td>
<td>'.$excel_row["lastname"].'</td>
<td>'.$excel_row["agerange"].'</td>
<td>'.$excel_row["gender"].'</td>
<td>'.$excel_row["city_municipality"].'</td>
<td>'.$excel_row["province"].'</td>
<td>'.$excel_row["mobileno"].'</td>
<td>'.$excel_row["email"].'</td>
<td>'.$excel_row["org_office"].'</td>
<td></td>
</tr>
';
$no ++;
}
$excel_output .='</table>';
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=Attendance Sheet.xls");
echo $excel_output;
}
}
And here is the sample output of my code:
enter image description here
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.
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);
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.
i have some link which show data on iframe with the help of temporary data from database
i am fetching this data with the help of query strings
the page with Links 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("dbname");
$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>
Now the link from above page fetch data with the help of query string at this page a temporary table is created by collectiong data from various tables
but am getting error while retrieve data from that temporary table
the page with temporary table is
<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'];
echo "1".$indexname. "<br>";
$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,nse_index_constituents.NSE_Index_Name
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);
echo "2".$indexname. "<br>";
while($row1=mysql_fetch_array($result))
{
$Symbol1=$row1['Symbol'];
$CompanyName1=$row1['CompanyName'];
$HighPrice1=$row1['HighPrice'];
$LowPrice1=$row1['LowPrice'];
$LastTradedPrice1=$row1['LastTradedPrice'];
$ClosePrice1=$row1['ClosePrice'];
$NetChange1=$row1['NetChange'];
$PercentChange1=$row1['PercentChange'];
$Tickerplant_index_code1=$row1['Tockerplant_index_code1'];
$NSE_Index_Name1=$row1['NSE_Index_Name'];
}
echo "3".$indexname. "<br>";
$tbl="create GLOBAL TEMPORARY TABLE temppice(Symbol varchar(100),CompanyName varchar(200),HighPrice float(50),LowPrice float(50),LastTradedPrice float(50),ClosePrice float(50),NetChange float(50),PercentChange float(50),Tickerplant_index_code varchar(100),NSe_Index_Name varchar(100)) ON COMMIT DELETE ROWS;";
$res=mysql_query($tbl);
if (!$res) { die('Temporary table creation failed: ' . mysql_error()); }
if(mysql_error())die(mysql_error());
$intbl="Insert into temppice values('$Symbol1','$CompanyName1','$HighPrice1','$LowPrice1','$LastTradedPrice','$ClosePrice1','$NetChange1','$PercentChange1','$Tockerplant_index_code1','$NSE_Index_Name1')";
mysql_query($intbl);
if(mysql_error())die(mysql_error());
echo "4".$indexname. "<br>";
$query1="Select * from temppice where NSE_Index_Name=$indexname";
$result1=mysql_query($query1);
//if(mysql_error())die(mysql_error());
mysql_connect("localhost","dbname","password");
mysql_select_db("dbname");
while($row=mysql_fetch_array($result1, MYSQL_BOTH))
{
$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>
the error am getting is
Temporary table creation failed: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'GLOBAL TEMPORARY TABLE
temppice(Symbol varchar(100),CompanyName varchar(200),Hig' at line 1
According to the manual the MySQL CREATE TABLE syntax does not support the global keyword. That appears to be an Oracle thing. Likewise I believe that the ON COMMIT DELETE ROWS clause is part of the Oracle syntax which will not work in MySQL either.
If you remove those two parts it will probably work:
$tbl=<<<SQL
create TEMPORARY TABLE temppice (
Symbol varchar(100),
CompanyName varchar(200),
HighPrice float(50),
LowPrice float(50),
LastTradedPrice float(50),
ClosePrice float(50),
NetChange float(50),
PercentChange float(50),
Tickerplant_index_code varchar(100),
NSe_Index_Name varchar(100)
);
SQL;