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=mysql_query($query2); echo mysql_error(); $nume=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 ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; ////////////// 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 ORDER BY `5min_volume` DESC limit $eu, $limit "; $result=mysql_query($query); echo mysql_error(); //////////////// Now we will display the returned records in side the rows of the table///////// while($noticia = mysql_fetch_array($result)) { if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';} else{$bgcolor='#f1f1f1';} echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
 Symbol Open High Low Close Percent Change Volume
 $noticia[symbol] $noticia[DailyOpen] $noticia[DailyHigh] $noticia[DailyLow] ".$noticia['5min_close']." $noticia[PerChg] $noticia[PriChg] ".$noticia['5min_volume']."
"; ////////////////////////////// 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 "
"; ?>