| ";
echo "";
/*
$sql = "select exchvarid, exchvarietyname, LatestExchRates.exchangeid, exchangename, futureyear, futuremonth, projection, spottxt, last, buy, sell, last - settlementprice as changeval, chgn, settlementprice, open, high, low, volume, entrydate, entrytime, LatestExchRates.settleflag, (last - settlementprice)/settlementprice*100 as perchgn from LatestExchRates, ExchangeMaster, ExchVarietyMast where LatestExchRates.exchangeid in (33) and LatestExchRates.exchangeid = ExchangeMaster.exchangeid and exchvarid = exchvarietyid and date_format(entrydate, '%Y-%m-%d') = date_format(now(), '%Y-%m-%d') and ((last - settlementprice)/settlementprice*100) > 0 " . $filter . " order by perchgn desc, volume desc, exchangename desc, projection, futureyear, futuremonth limit 0,5";
$q->query($sql);
$ctr = 1;
while($q->next_record())
{
if($ctr == 1)
{
echo "| " . $q->f("exchangename") . " Top Gainers | ";
echo "| Variety | Contract | Last | Chg | % Chg | Volume | ";
}
echo "| " . $q->f("exchvarietyname") . " | " . $m_month[$q->f("futuremonth")-1] . "'" . substr($q->f("futureyear"),2) . " | " . number_format($q->f("last"),2,".","") . " | " . number_format($q->f("changeval"),2,".","") . " | " . number_format($q->f("perchgn"),2,".","") . " | " . $q->f("volume") . " | ";
$ctr++;
}
*/
$sql="select max(date_format(entrydate, '%Y-%m-%d')) as entrydate from LatestExchRates";
$q->query($sql);
$q->next_record();
$date=$q->f('entrydate');
$sql="select count(exchvarid) as c from LatestExchRates, ExchangeMaster, ExchVarietyMast where LatestExchRates.exchangeid in (33) and LatestExchRates.exchangeid = ExchangeMaster.exchangeid and exchvarid = exchvarietyid and date_format(entrydate, '%Y-%m-%d') = '".$date."' and ((last - settlementprice)/settlementprice*100) < 0 " . $filter . " order by $order1 asc";
$q->query($sql);
$q->next_record();
$coun=$q->f('c');
$sql = "select exchvarid, exchvarietyname, LatestExchRates.exchangeid, exchangename, futureyear, futuremonth, projection, spottxt, last, buy, sell, last - settlementprice as changeval, chgn, settlementprice, open, high, low, volume, entrydate, entrytime, LatestExchRates.settleflag, (last - settlementprice)/settlementprice*100 as perchgn from LatestExchRates, ExchangeMaster, ExchVarietyMast where LatestExchRates.exchangeid in (33) and LatestExchRates.exchangeid = ExchangeMaster.exchangeid and exchvarid = exchvarietyid and date_format(entrydate, '%Y-%m-%d') = '".$date."' and ((last - settlementprice)/settlementprice*100) < 0 " . $filter . " order by $order1 desc";
$q->query($sql);
$ctr = 1;
while($q->next_record())
{
if($ctr == 1)
{
echo "| " . $q->f("exchangename") . " Top Loser | ";
echo "| Variety | Contract | Last | Chg | % Chg | Volume | ";
}
$val=$q->f("exchvarietyname");
$val1=$m_month[$q->f("futuremonth")-1];
$val2=substr($q->f("futureyear"),2);
$val3=number_format($q->f("last"),2,".","");
$val4=number_format(abs($q->f("chgn")),2,".","");
$val5=$q->f("volume");
${"display".$ctr}=(array($val,$val1,$val2,$val3,$val4,$val5));
//echo "| " . $q->f("exchvarietyname") . " | " . $m_month[$q->f("futuremonth")-1] . "'" . substr($q->f("futureyear"),2) . " | " . number_format($q->f("last"),2,".","") . " | " . number_format($q->f("changeval"),2,".","") . " | " . number_format($q->f("perchgn"),2,".","") . " | " . $q->f("volume") . " | | ";
$ctr++;
}
for($i=$ctr-1; $i>0; $i--){
echo "| " . ${"display".$i}[0] . " | " . ${"display".$i}[1] . "'" . ${"display".$i}[2] . " | " . ${"display".$i}[3] . " | " . ${"display".$i}[3] . " | " . ${"dissplay".$i}[4] . " | " . ${"display".$i}[5] . " | | ";
}
if($ctr == 1)
{
echo "| No losers found | ";
}
echo " | | ";
$common_footer=join(" ", file('http://127.0.0.1/eagritrader/common/footer_mcx.php?pages=MTL&cid=".$cid."&varid=".$varid&top=2'));
echo " |