require "../bt-database/config.php"; // All database details will be included here
$page_name="intraday-gainers.php"; // If you use this code with a different page ( or file ) name then change this
if(!empty($_GET['start']))
{
$start=$_GET['start'];
} else {
$start=0;
} // To take care global variable if OFF
if(!($start > 0)) { // This variable is set to zero for the first page
$start = 0;
}
$eu = ($start -0);
$limit = 50; // No of records to be shown per page.
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
/////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
$query2="SELECT symbol,DailyOpen,DailyHigh,DailyLow,5min_close,PerChg,PriChg,5min_volume FROM 5min_mkt_temp";
$result2=$con->query($query2);
echo $con->error;
$nume=$result2->num_rows;//mysql_num_rows($result2);
/////// The variable nume above will store the total number of records in the table////
/////////// Now let us print the table headers ////////////////
$bgcolor="#f1f1f1";
echo "
";
echo " Symbol | ";
echo " Open | ";
echo " High | ";
echo " Low | ";
echo " LTP | ";
echo " Percent | ";
echo " Change | ";
echo " Volume |
";
////////////// Now let us start executing the query with variables $eu and $limit set at the top of the page///////////
$query=" SELECT symbol,DailyOpen,DailyHigh,DailyLow,5min_close,PerChg,PriChg,5min_volume FROM 5min_mkt_temp where 5min_volume > '0' ORDER BY `PerChg` DESC limit $eu, $limit ";
$result=$con->query($query);
echo $con->error();
//////////////// Now we will display the returned records in side the rows of the table/////////
while($noticia = $result->fetch_array())
{
if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
else{$bgcolor='#f1f1f1';}
echo "";
echo " $noticia[symbol] | ";
echo " $noticia[DailyOpen] | ";
echo " $noticia[DailyHigh] | ";
echo " $noticia[DailyLow] | ";
echo " ".$noticia['5min_close']." | ";
echo " $noticia[PerChg] | ";
echo " $noticia[PriChg] | ";
echo " ".$noticia['5min_volume']." | ";
echo "
";
}
echo "
";
////////////////////////////// End of displaying the table with records ////////////////////////
///// Variables set for advance paging///////////
$p_limit=50; // This should be more than $limit and set to a value for whick links to be breaked
if(!empty($_GET['p_f'])) {
$p_f=$_GET['p_f'];
} else {
$p_f=0 ;
} // To take care global variable if OFF
if(!($p_f > 0)) { // This variable is set to zero for the first page
$p_f = 0;
}
$p_fwd=$p_f+$p_limit;
$p_back=$p_f-$p_limit;
//////////// End of variables for advance paging ///////////////
/////////////// Start the buttom links with Prev and next link with page numbers /////////////////
echo "
";
if($p_f<>0){print "PREV $p_limit"; }
echo " | ";
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
if($back >=0 and ($back >=$p_f)) {
print "PREV";
}
//////////////// Let us display the page links at center. We will not display the current page as a link ///////////
echo " | ";
for($i=$p_f;$i < $nume and $i<($p_f+$p_limit);$i=$i+$limit){
if($i <> $eu){
$i2=$i+$p_f;
echo " $i ";
}
else { echo "$i";} /// Current page is not displayed as link and given font color red
}
echo " | ";
///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
if($this1 < $nume and $this1 <($p_f+$p_limit)) {
print "NEXT";}
echo " | ";
if($p_fwd < $nume){
print "NEXT $p_limit";
}
echo " |
";
?>