我有一些链接,可以借助数据库中的临时数据显示iframe上的数据 我在查询字符串
的帮助下获取此数据包含链接的页面是
<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><a href="http://mastertrade.in/master/wpfiles/gtnsegainers.php?tpnt=<?php echo $tpnt;?>&indexname=<?php echo $indexname;?>" target="fr"><?php echo $indexname;?></a><br></td>
</tr>
<?php }?>
</div>
<div class="fr">
<iframe height="780" width="780" scrolling="no" name="fr"></iframe>
</div>
现在来自上一页的链接在此页面的查询字符串的帮助下获取数据,临时表由各种表中的collectiong数据创建 但是从该临时表中检索数据时出现错误
临时表的页面是
<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>
我得到的错误是
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
答案 0 :(得分:3)
TEMPORARY
表具有一个连接的生命周期,因此如果您在浏览器的一个请求期间创建表,然后想要在另一个请求中从中获取数据....它就不再存在了。该表不存在,您的查询因no such table in database
错误而失败。