简体   繁体   English

从Equi Join查询创建的表中获取数据

[英]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 我有一个由我的sql equijoin创建的表,并且我想通过获取错误从该表中检索数据,错误是

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

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 gtnsegainer.php页面出现错误是gtnsegainer页面在iframe中,此页面根据上一页的链接从数据库中检索数据

<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); 在特定的设置中很难说出错误是什么,但是我建议在每个mysql_query($ query)之后添加一些简单的调试方法 add if(mysql_error())die(mysql_error()); 添加if(mysql_error())die(mysql_error()); and that will point you in the right direction. 这将为您指明正确的方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM