include_once('config.inc.php'); ?> $prd_link_sql = mysql_query("select * from sub_cats order by sub_cat_id ASC LIMIT 1"); $rs_prd_link = mysql_fetch_array($prd_link_sql); ?> $maincatid = $_REQUEST['mcatid']; $subcatid = $_REQUEST['scatid']; $page = $_REQUEST['page']; // main_cat $get_m_q = mysql_query("select * from main_cats where main_cat_id = '$maincatid'"); $ar_m = mysql_fetch_array($get_m_q); //sub cat $get_s_q = mysql_query("select * from sub_cats where sub_cat_id = '$subcatid'"); $ar_s = mysql_fetch_array($get_s_q); ?> $news_sql = mysql_query("select * from news_events order by n_sorting_order"); ?> $prdid = $_REQUEST['prdid']; $_SESSION['link'] = $prdid; $cur_prds_rs = mysql_query("select * from products where prdid='$prdid'"); $cur_prds = mysql_fetch_array($cur_prds_rs); extract($cur_prds); $_SESSION['large_prdid'] = $image_file; if (!empty($size)){ $ar_size = explode(",",$size); } if (!empty($colours)){ $ar_color = explode(",",$colours); } ?> // total products in this category $sql_ttl_p = mysql_query("select * from products where sub_cat_id = '$subcatid' AND publish = 'y' order by prdid") or die(mysql_error()); //================================= //============= getting current offset of product =========== $total_p_ar = array(); while($total_p = mysql_fetch_array($sql_ttl_p)) { $total_p_ar[] = $total_p['prdid']; } $current_pid = array_search($prdid , $total_p_ar); $final_pos = $current_pid+1; // because array starst from 0 key //=========================================================== $sql1 = mysql_query("select prdid from products where prdid > '$prdid' AND sub_cat_id = '$subcatid' AND publish = 'y' order by prdid limit 1") or die(mysql_error()); if($inf = mysql_fetch_array($sql1)){ // A next record is found $next = $inf["prdid"]; // Set $id to the next ID }else { $nonext = 0; } //below is previous record in mysql $sql1 = mysql_query("select prdid from products where prdid < '$prdid' AND sub_cat_id = '$subcatid' AND publish = 'y' order by prdid desc limit 1") or die(mysql_error()); if($inf2 = mysql_fetch_array($sql1)){ // A previous record is found $previous = $inf2["prdid"]; // Set $id to the previous ID }else { $noprevious = 0; } // print_r($total_p_ar); // getting end product $end_id = end($total_p_ar); // getting First product $first_id = $total_p_ar[0]; ?>