Commodities

'".$cutoff."' and category='Commodity') as result order by ent_date"; #echo "
".$news_sql; $q->query($news_sql); $tot = $q->num_rows(); if ($pageno=="") { $st=0; $pageno=1; } else $st=($pageno-1)*15; if($next=="" && $prev=="") { $next=0; $nn=$next*10; $ll=$nn+10; } else if($prev>1) { $nn=($prev-1)*10; $ll=$nn+10; $pre=$prev-1; $next=$pre; } else { $nn=$next*10; $ll=$nn+10; $pre=$next; } if($next=="") $next=0; $show_url=strtolower(str_replace(" ","",$showcat)); $show_url=strtolower(str_replace("'","",$show_url)); $total_count=$tot; $news_count=$total_count; $total_count=$total_count/15; $total_count=ceil($total_count)-1; if(($total_count*15)<$tot) $total_count++; $pagecount=0; $pageall=""; $nex=""; while ($pagecount!=$total_count) { $pagecount++; if($pagecount>$nn && $pagecount<=$ll) { if ($pagecount==$pageno) $pageall .= "
  • $pagecount
  • \n"; else { $pageall .= "
  • ".$pagecount."
  • \n"; } $last_cc=$pagecount+1; } else if($pagecount>$ll) { $nex=$next+1; break; } } if($total_count > 1) { if($nex!="") { $pageall .= "
  • Next »
  • \n"; } else { $pageall .= "
  • Next »
  • \n"; } } #$pageall .= "
    "; if($total_count > 1) { if($nex>1 || $pre>=1) { $last_pr=$last_cc-20; if($last_pr<1) $last_pr=1; $pageall = "
  • « Previous
  • \n".$pageall; } else { $pageall = "
  • « Previous
  • \n".$pageall; } } else { #$pageall = "
    ".$pageall; } $news_sql = $news_sql . " desc limit $st,15"; #echo $news_sql;exit; $ctr=0; $q->query($news_sql); while($q->next_record()) { $news_cat = $q->f('news_cat'); $scid = $q->f('scid'); $autono = $q->f('autono'); $heading = $q->f('heading'); $summary = $q->f('summary'); $impact = $q->f('impact'); $category = $q->f('category'); $exp_img_path = $q->f('exp_img_path'); $target = $q->f('target'); $rec_price = $q->f('recprice'); $stock = $q->f('stock'); $call_cat = $q->f('cat'); $expiry_date = $q->f('expiry_date'); if($category == "MultiBaggers" || $category == "MktOutlook") $ent_date = $q->f('call_date'); else $ent_date = $q->f('ent_date'); $diff = $q->f('diff'); $msg_dat=substr($ent_date,0,10); $msg_yr=substr($ent_date,0,4); $curr_dat=date("Y-m-d"); $curr_yr=date("Y"); if($curr_dat!=$msg_dat) { $date_all = explode(" ",$ent_date); $time_xpld = explode(":",$date_all[1]); $date_xpld = explode("-",$date_all[0]); if($curr_yr==$msg_yr) { $filing_dt = date("g.i A M jS", mktime($time_xpld[0], $time_xpld[1], 0, $date_xpld[1], $date_xpld[2], $date_xpld[0])); } else { $filing_dt = date("g.i A M jS Y", mktime($time_xpld[0], $time_xpld[1], 0, $date_xpld[1], $date_xpld[2], $date_xpld[0])); } } else { $filing_dt = dateTimeDiff($ent_date)." ago"; } $exp_name = $impact; $expimg = $expimg_arr[$exp_name]; $expdesig = $expdes_arr[$exp_name]; $stop_loss = $rec_price; $disp_exp_name = ""; if(in_array($exp_name,$experts_array))$width = '60px'; else $width = '100px'; $expimg = ""; if(strlen($scid)>0 and $call_cat!="Commodity") { $stock_name = stock_price($scid,"NSE","","1"); if($stock_name == "") { $stock_name = stock_price($scid,"BSE","","1"); } } else if(strlen($scid) > 0 and $call_cat == "Commodity") { $get_mcx_price = "select ltp, ltt, close, cont_symbol, cont_expiry from mcx_commodity where cont_symbol='".$scid."' and expiry_date='".$expiry_date."'"; #echo "
    ".$get_mcx_price; $q2->query($get_mcx_price); if($q2->next_record()){ $ltp = $q2->f("ltp"); $last_trd_time = $q2->f("ltt"); $cont_symbol = $q2->f("cont_symbol"); $cont_expiry = $q2->f("cont_expiry"); $close = $q2->f("close"); $last_trd_time = explode(" ",$last_trd_time); $date = explode("-",$last_trd_time[0]); $time = explode(":",$last_trd_time[1]); $feed_time = date("M d, G:i",mktime($time[0],$time[1],$time[2],$date[1],$date[2],$date[0])); $per = number_format(((($ltp-$close)/$close)*100),2); if ($per>0) { $image_class=""; $fontcolor="gr_18"; } else if ($per<0) { $image_class=""; $fontcolor="r_18"; } else { $image_class=""; $fontcolor="b_18"; } $stock_name = "

    ".$cont_symbol." ".$cont_expiry."

    ".$ltp."".$image_class."".$per."%MCX ".$feed_time."

    "; }else{ $stock_name = ""; } }else{ $stock_name = ""; } $det_flag = 0; $det_disp = "
    "; if($target != "" && $target != 0) { $det_flag = 1; $det_disp .= "

    TARGET ".number_format($target,2)."

    "; } if($stop_loss != "" && $stop_loss != 0) { $det_flag = 1; $det_disp .= "

    STOP LOSS".number_format($stop_loss,2)."

    "; } if($det_flag == 1) $det_disp .= "

    "; else $det_disp = ""; if($category == "BUY") $image_name = ""; else if($category == "SELL") $image_name = ""; else $image_name = ""; if($call_cat == "Commodity") { $disp_cat = "COMMODITY CALL"; $hd_style = "font: 13px/15px Arial"; } else { $disp_cat = "POWER CALL"; $hd_style = ""; } echo "

    ".$disp_cat."

    ".$expimg."

    ".$disp_exp_name."

    ".$expdesig."

    ".$filing_dt."

    ".$image_name."

    ".$stock_name."

    ".$det_disp."

    ".$heading."

    "; $ctr++; } ### Code for pagination ends here #### ?>