Jump to content

need help with allowing a next link


perezf

Recommended Posts

currently i created this which makes a drop down box with a list of the pages i need help in making each number actually link to the next page

im stuck and i could really use some help

 

the next page link and previous link work i just need the drop down to work below is the script for the drop down

 

 

$current .= '<form action="">';
$current .= '<select name="selectFRANK" id="select">';
$current_page = $f[current_page];
for ($i = 1; $i < $current_page; $i++) {
$current .= '<option>'.$i.'</option>';}

$current .= '<option selected="selected">'.$current_page.'</option>';
$max_pages = $f[total_page];
for($k = ($current_page + 1); $k <= $max_pages; $k++) {
$current .= "<option value=\"$k\">".$k.'</option>';}

$current .= '</select>';
$current .= '<input type="submit" value="Go" name="btnsubmit" />';
$current .= '</form>';

 

 

 

 

 

 

this is the entire code for that page

 

<?
// Basic Admin tools

function recursive_stat_fetch($user_id,$stat_pass)
{
$s = lib_getsql("SELECT count(id) as ads, sum(clicks) as tclick, sum(impressions) as tviews, sum(amount) as tamount FROM adrev_ads WHERE userid='".$user_id."' GROUP BY userid");
$stats = $s[0];
$stat_pass[ads] += $stats[ads];
$stat_pass[tclick] += $stats[tclick];
$stat_pass[tviews] += $stats[tviews];
$stat_pass[tamount] += $stats[tamount];
$sql="select * from adrev_users where parent='".$user_id."'";
$u = lib_getsql($sql);
if(count($u) > 0)
{
	foreach($u as $rec)
	{
		$stat_pass = recursive_stat_fetch($rec[id],$stat_pass);
	}
}
return $stat_pass;
}








class admin
{
var $tpl;

function admin()
{
	global $section, $action, $f;

	$this->tpl = new XTemplate("admin.html");

	if($action == "settings")
	{
		include_once("settings.php");
		exit;
	}

	if(!$_SESSION[user][admin])
	{
		lib_redirect("You must be administrator", "index.php");
		exit;
	}

	if($action == "bonus")
		$this->bonus();

	if($action == "advertisers")
		$this->advertisers();

	if($action == "stats")
		$this->stats();

	if($action == "ads")
		$this->ads();

	if($action == "blast")
		$this->blast();

	if($action == "activate" || $action == "renew" || $action == "deactivate")
	{
		$this->change_status();
	}

	if($action == "del_ad" && $f[id])
		$this->delete_ad();
	if($action == "del_user" && $f[id]);
		$this->delete_user();

	exit;
}

// Give bonus to an ad
function bonus()
{
	global $f, $DEFAULT;

	// Get the ad
	$ad = lib_getsql("SELECT * FROM adrev_ads WHERE id='$f[id]'");
	if(!$ad[0][id])
	{
		lib_redirect("There was an error loading that ad.", "index.php?section=admin&action=ads", 3);
		exit;
	}
	$rec = $ad[0];

	// Process the bonus
	if($f[bonus] && $f[id])
	{
		// Add it
		if($rec[rate_type] == 1)
		{
			lib_getsql("UPDATE adrev_ads SET amount=amount+$f[bonus] WHERE id='$f[id]'");
			$msg = "$f[bonus] dollars were added to your ad.";
		}
		elseif($rec[rate_type] == 2)
		{
			lib_getsql("UPDATE adrev_ads SET quan=quan+$f[bonus] WHERE id='$f[id]'");
			$msg = "$f[bonus] impressions were added to your ad.";
		}
		elseif($rec[rate_type] == 3)
		{
			$d = $f[bonus] * 86400;
			lib_getsql("UPDATE adrev_ads SET expire_date=expire_date+$d, quan=quan+$f[bonus] WHERE id='$f[id]'");
			$msg = "$f[bonus] days were added to your ad.";
		}

		// Send an email
		$uinfo = lib_getsql("SELECT * FROM adrev_users WHERE id='$rec[userid]'");
		$m = "Dear user,\n\n";
		$m .= $msg . "\n\n";
		$m .= "Title: $rec[title]\n\n";
		$m .= "Best regards\n";
		$m .= "The $DEFAULT[site_name] support team\n";
		$m .= "$DEFAULT[email]\n";
		$m .= "$DEFAULT[site_url]\n";
		mail($uinfo[0][email], "[ $DEFAULT[site_name] ] - Bonus added to your ad", $m, $DEFAULT[support_email]);

		// Done
		lib_redirect("The bonus was added successfully", "index.php?section=admin&action=ads", 2);
		exit;
	}

	// Show the form
	if($rec[rate_type] == 1)
	{
		// CPC
		$this->tpl->assign("BONUS", "clicks");
		$this->tpl->assign("ADDBONUS", "Add extra dollars to this ad");
	}
	elseif($rec[rate_type] == 2)
	{
		// CPM
		$this->tpl->assign("BONUS", "impressions");
		$this->tpl->assign("ADDBONUS", "Add extra impressions to this ad");
	}
	elseif($rec[rate_type] == 3)
	{
		// CPM
		$this->tpl->assign("BONUS", "days");
		$this->tpl->assign("ADDBONUS", "Add extra days to this ad");
	}

	$this->tpl->assign("TITLE", stripslashes($rec[title]));
	$this->tpl->assign("CLICKS", number_format($rec[clicks]));
	$this->tpl->assign("IMPRESSIONS", number_format($rec[impressions]) . iif($rec[rate_type]==2, " of " . number_format($rec[quan]),""));
	$this->tpl->assign("DAYS", iif($rec[rate_type] == 3, $rec[quan] . " - " . number_format(($rec[expire_date] - time()) / 86400,1) . " days left", "N/A"));
	$this->tpl->assign("DOLLARS", number_format($rec[amount],2));
	$this->tpl->assign("ID", $f[id]);
	$this->tpl->parse("bonus");

	lib_output($this->tpl->text("bonus"), "Ad Bonus");
	exit;
}


// Delete user and all ads\logs
function delete_user()
{
	global $f;

	// Delete Any ads and logs
	$ads = lib_getsql("SELECT id FROM adrev_ads WHERE userid='$f[id]'");
	if(count($ads) > 0 && $_SESSION[user][admin] == 1)
	{
		foreach($ads as $rec)
		{
			lib_getsql("DELETE FROM adrev_clicks WHERE adid='$rec[id]'");
			lib_getsql("DELETE FROM adrev_map WHERE adid='$rec[id]'");
			lib_getsql("DELETE FROM adrev_ads WHERE id='$rec[id]'");
		}
	}

	lib_getsql("DELETE FROM adrev_users WHERE id='$f[id]'");

	lib_redirect("The user, their ads, logs and keywords were deleted", "index.php?section=admin&action=advertisers", 2);
	exit;
}

// Delete an ad
function delete_ad()
{
	global $f;

	// Delete any logs
	lib_getsql("DELETE FROM adrev_clicks WHERE adid='$f[id]'");

	// Delete any keywords
	lib_getsql("DELETE FROM adrev_map WHERE adid='$f[id]'");

	// Delete the ad
	lib_getsql("DELETE FROM adrev_ads WHERE id='$f[id]'");

	lib_redirect("The ad was deleted", "index.php?section=admin&action=ads", 2);
	exit;
}

// Send an email blast
function blast()
{
	global $f, $DEFAULT;

	if($f[email] && $f[subject] && $f[message])
	{
		$f[subject]  = stripslashes($f[subject]);
		$f[message]  = stripslashes($f[message]);
		$f[message] .= "\n----------------------------------------\n";
		$f[message] .= "You received this message because you are ";
		$f[message] .= "an advertiser at $DEFAULT[name]\n$DEFAULT[site_url]";

		if(!$f[test])
		{
			$data = lib_getsql("SELECT email FROM adrev_users ORDER BY email");
			$emails = array();
			foreach($data as $rec)
			{
				$emails[] = $rec[email];
			}

			// BCC List
			$bcc = implode(",", $emails);
			mail($f[email], "[$DEFAULT[name]] $f[subject]", $f[message], "From: $DEFAULT[name] <$f[email]>\r\nBcc: $bcc");
			lib_redirect("Your message was sent to all advertisers", "index.php", 3);
			exit;
		}
		else
		{
			mail($f[email], "[$DEFAULT[name]] $f[subject]", $f[message], "From: $f[email]");
			lib_redirect("Your email was sent to $f[email]", "index.php", 2);
			exit;
		}
	}

	$this->tpl->assign("EMAIL", iif(!$f[email],$DEFAULT[email], $f[email]));
	$this->tpl->assign("SUBJECT", stripslashes($f[subject]));
	$this->tpl->assign("MESSAGE", htmlentities(stripslashes($f[message])));
	$this->tpl->parse("blast");

	$out = $this->tpl->text("blast");
	lib_output($out, "Send Email Message to Advertisers");
	exit;
}

// Change status of ad
function change_status()
{
	global $f, $action;

	if($action == "activate")
	{
		lib_status($f[id], "activate");
		lib_redirect("The ad was activated and a message was sent to the user", "index.php?section=admin&action=ads", 1);
		exit;
	}

	if($action == "deactivate")
	{
		if($f[id] && $f[reason])
		{
			lib_status($f[id], "deactivate", 1, $f[reason]);
			lib_redirect("The ad was deactivated and a message was sent to the user", "index.php?section=admin&action=ads", 2);
			exit;
		}

		// Grab the ad
		$a = lib_getsql("SELECT * FROM adrev_ads WHERE id='$f[id]'");
		$rec = $a[0];

		// Show the simple form
		$out  = "<font size=3 face=Arial,Helvetica,sans-serif><b>Deactivate an Ad</b><p>\n";
		$out .= "<code>";
		$out .= "<a href=$rec[url] target=new>$rec[title]</a><br>$rec[description]<p>\n";
		$out .= "<code>\n";
		$out .= "<form method=post action=index.php>\n";
		$out .= "<b>Reason for Deactivation:</b><br>\n";
		$out .= "<textarea name=f[reason] rows=4 cols=50></textarea><br>\n";
		$out .= "<input type=submit value='Send and Deactivate'>\n";
		$out .= "<input type=hidden name=section value=admin>\n";
		$out .= "<input type=hidden name=action value=deactivate>\n";
		$out .= "<input type=hidden name=f[id] value=$f[id]>\n";
		$out .= "</form>\n\n";

		lib_output($out, "Deactivate an ad");
		exit;
	}

	if($action == "renew")
	{
		lib_status($f[id], "renew");
		lib_redirect("The ad was renewed and a message was sent to the user", "index.php?section=admin&action=ads", 1);
		exit;
	}

	lib_redirect("Please enter a valid action", "index.php&section=ads", 1);
	exit;
}

















// View Ads
function ads()
{
	global $f;

// modified by nir
	if($_SESSION[user][super_admin] == 1)
	{
	if(isset($_GET['sch']))
	{
	$sch=$_GET['sch'];
$data = lib_getsql("SELECT a.*,b.name as zname,c.login,c.password 
							FROM adrev_ads a, adrev_zones b, adrev_users c 
							WHERE a.zone=b.id AND a.userid=c.id AND a.title LIKE '%$sch%' 
							ORDER BY date DESC LIMIT 200");
	}
	else
        {
// this was default, for roll back, use the below sql only.
	$data = lib_getsql("SELECT a.*,b.name as zname,c.login,c.password 
							FROM adrev_ads a, adrev_zones b, adrev_users c 
							WHERE a.zone=b.id AND a.userid=c.id 
							ORDER BY date DESC LIMIT 200");
	}
	}
	else
	{

	if(isset($_GET['sch']))
	{
	$sch=$_GET['sch'];
         $data = lib_getsql("SELECT a.*,b.name as zname,c.login,c.password 
							FROM adrev_ads a, adrev_zones b, adrev_users c 
							WHERE a.zone=b.id AND a.userid=c.id AND a.title LIKE '%$sch%' AND c.parent=".$_SESSION[user][id]." 
							ORDER BY date DESC LIMIT 200");
	}

	else{
	$data = lib_getsql("SELECT a.*,b.name as zname,c.login,c.password 
							FROM adrev_ads a, adrev_zones b, adrev_users c 
							WHERE a.zone=b.id AND a.userid=c.id AND c.parent=".$_SESSION[user][id]."
							ORDER BY date DESC LIMIT 200");
	}
	}
// end of modification



// sorting section ... start frank
	if(!$f[order_by])
		$f[order_by] = "`login`";

	if($f[change_order] == 1)
	{
		if($f[asc]=="ASC")
		{
			$f[asc] = "DESC";
		}
		else if($f[asc]=="DESC")
		{
			$f[asc] = "ASC";
		}
	}

	if(!$f[asc])
		$f[asc] = "ASC";


	if(($f[order_by] == "`login`") || ($f[order_by] == "`parent`"))
	{
		$sql .= " ORDER BY c.".$f[order_by]." " . $f[asc];
	}
	else
	{
		$sql .= " ORDER BY a.".$f[order_by]." " . $f[asc];
	}


//		$sql .= " group by a.userid ";
	if(isset($_GET['sch']))
	{
	$sch=$_GET['sch'];
	$sort_url_base="/ads/index.php?section=admin&action=ads&sch=$sch&f[asc]=".$f[asc]."&f[change_order]=1&f[parent]=".$f[parent]."&f[order_by]=";
	}
	else
	{
	$sort_url_base="/ads/index.php?section=admin&action=ads&f[asc]=".$f[asc]."&f[change_order]=1&f[parent]=".$f[parent]."&f[order_by]=";

	}



	$sort_user_url=$sort_url_base."`login`";
	$sort_salesperson_url=$sort_url_base."`parent`";
	$sort_date_url=$sort_url_base."`date`";
	$sort_expires_url=$sort_url_base."`expire_date`";
	$sort_title_url=$sort_url_base."`title`";
	$sort_type_url="#";
	$sort_clicks_url="#";
	$sort_viwes_url="#";
	$sort_ctr_url="#";
	$sort_paid_url="#";

// sorting section ... end



// paging section... start
	if($f[parent] == "")
	{
		if($_SESSION[user][super_admin] == 1)
		{
			$f[parent] = "%";
		}
		else
		{
			$f[parent] = $_SESSION[user][id];
		}
	}

if(isset($_GET['sch']))
{
$sql = "SELECT a.*,b.name as zname,c.login,c.password,c.parent FROM adrev_ads a, adrev_zones b, adrev_users c WHERE a.zone=b.id AND a.userid=c.id  AND a.title LIKE '%$sch%' AND c.parent like '".$f[parent]."'".$sql;
}
else{		$sql = "SELECT a.*,b.name as zname,c.login,c.password,c.parent FROM adrev_ads a, adrev_zones b, adrev_users c WHERE a.zone=b.id AND a.userid=c.id AND c.parent like '".$f[parent]."'".$sql;

}
/*
the main variables, with the href part as well are:
$first $previous $current $next $last
*/

// set the page limit
	if(!$f[page_limit])
		$f[page_limit]=200;

// set the current page
	if(!$f[current_page])
		$f[current_page]=1;

// calculate the total page
	if(!$f[total_page])
	{
		$cnt = lib_getsql($sql);
		if(count($cnt) > 0)
		{
			$f[total_page]=ceil( count($cnt) / $f[page_limit] );
		}
	}

// alter the sql now...
	$sql .= " limit " . ( ($f[current_page] - 1)*$f[page_limit] ) . " , " . $f[page_limit];




// construct the url base...
	$url_base="<a href=\"/ads/index.php?section=admin&action=ads&f[page_limit]=" . $f[page_limit] . "&f[total_page]=" . $f[total_page] . "&f[order_by]=".$f[order_by]."&f[asc]=".$f[asc]."&f[parent]=".$f[parent]."&f[current_page]=";


	$first=$url_base . 1 ."\">First</a>";

	if(($f[current_page]-1) <= 0)
	{
		$previous=" ";
	}
	else
	{
		$previous=$url_base . ($f[current_page]-1) . "\">Previous</a>";
	}
	$current_page = $f[current_page];
	$current="Current Page: " . $f[current_page] . "/" . $f[total_page];


$current .= '<form action="">';
$current .= '<select name="selectFRANK" id="select">';
$current_page = $f[current_page];
for ($i = 1; $i < $current_page; $i++) {
$current .= '<option>'.$i.'</option>';}

$current .= '<option selected="selected">'.$current_page.'</option>';
$max_pages = $f[total_page];
for($k = ($current_page + 1); $k <= $max_pages; $k++) {
$current .= "<option value=\"$k\">".$k.'</option>';}

$current .= '</select>';
$current .= '<input type="submit" value="Go" name="btnsubmit" />';
$current .= '</form>';


	if(($f[current_page]+1) > $f[total_page])
	{
		$next=" ";
	}
	else
	{
		$next=$url_base . ($f[current_page]+1) . "\">Next</a>";
	}

	$last=$url_base . $f[total_page] . "\">Last</a>";

//echo $sql;

	$data = lib_getsql($sql);

// paging section end






	if(count($data) > 0)
	{
		foreach($data as $rec)
		{
			if(($rec[login] != $last_user) || ($rec[login] == $f[expand_user]))
			{

			$this->tpl->assign("LOGIN", $rec[login]);
			if(isset($_GET['sch']))
			{
			$this->tpl->assign("LOGIN", $rec[login]);
			}
			$this->tpl->assign("PASSWORD", $rec[password]);
			$this->tpl->assign("DATE", str_replace(" ", " ", date("m/d/y", $rec[date])));
			$this->tpl->assign("TITLE", stripslashes($rec[title]));
			if($rec[expire_date] > 0)
				$this->tpl->assign("EXPIRES", str_replace(" ", " ", date("m/d/y", $rec[expire_date])));
			else
				$this->tpl->assign("EXPIRES", "n/a");

			if($rec[rate_type] == 1)
				$this->tpl->assign("TYPE", "CPC");
			elseif($rec[rate_type] == 2)
				$this->tpl->assign("TYPE", "CPM");
			else
				$this->tpl->assign("TYPE", "Days");

			$bgcolor = iif($bgcolor== "#FFFFFF", "#FFFFEE", "#FFFFFF");
			$this->tpl->assign("BGCOLOR", $bgcolor);
			$action = "";
			if($rec[status] == -1)
			{
				$this->tpl->assign("EXP", "#CC0000");
				$action = "<a href=index.php/admin/activate/$rec[id]>Activate</a>";
			}
			elseif($rec[status] == 0)
			{
				$this->tpl->assign("EXP", "#999999");
				$action = "<a href=index.php/ads/renew/$rec[id]>Renew</a>";
			}	
			elseif($rec[status] == -2)
			{
				$this->tpl->assign("EXP", "orange");
				$action = "<a href=index.php/admin/activate/$rec[id]>Reactivate</a>";
			}
			else
			{
				$this->tpl->assign("EXP", "#000000");
				$action  = "<a href=index.php/admin/bonus/$rec[id] title=\"Give a bonus to this advertiser\">Bonus</a> | ";
				$action .= "<a href=index.php/admin/deactivate/$rec[id] title=\"Deactivate this ad\">Deactivate</a>";
			}

			$action .= " | <a href=index.php/admin/del_ad/$rec[id] title=\"Delete this ad\">Delete</a>";
			$this->tpl->assign("ACTION", $action);
			$this->tpl->assign("CLICKS", number_format($rec[clicks]));
			$this->tpl->assign("VIEWS", number_format($rec[impressions]));
			$this->tpl->assign("CTR", number_format(($rec[clicks] * 100)/iif(!$rec[impressions],1,$rec[impressions]),1));
			$this->tpl->assign("PAID", $rec[amount]);
			$this->tpl->assign("URL", $rec[url]);
			$this->tpl->assign("ID", $rec[id]);
			$this->tpl->assign("EXPAND_USER_URL", $url_base.$f[current_page]."&f[expand_user]=".$rec[login]);

// sales person check up
			$sr = lib_getsql("select * from adrev_users where id = ".$rec[parent]);
			if($sr[0][admin] == 4)
			{
				$this->tpl->assign("SALESPERSON", $sr[0][name]);
			}
			else
			{
				$this->tpl->assign("SALESPERSON", "Self");
			}
// done
			$this->tpl->parse("view.list");

			}

			$last_user = $rec[login];
		}
	}


// for paging
	$this->tpl->assign("FIRST", $first);
	$this->tpl->assign("PREVIOUS", $previous);
	$this->tpl->assign("CURRENT", $current);
	$this->tpl->assign("NEXT", $next);
	$this->tpl->assign("LAST", $last);
// paging done

// for sorting
	$this->tpl->assign("SORT_USER_URL", $sort_user_url);
	$this->tpl->assign("SORT_SALESPERSON_URL", $sort_salesperson_url);
	$this->tpl->assign("SORT_DATE_URL", $sort_date_url);
	$this->tpl->assign("SORT_EXPIRES_URL", $sort_expires_url);
	$this->tpl->assign("SORT_TITLE_URL", $sort_title_url);
	$this->tpl->assign("SORT_TYPE_URL", $sort_type_url);
	$this->tpl->assign("SORT_CLICKS_URL", $sort_clicks_url);
	$this->tpl->assign("SORT_VIWES_URL", $sort_viwes_url);
	$this->tpl->assign("SORT_CTR_URL", $sort_ctr_url);
	$this->tpl->assign("SORT_PAID_URL", $sort_paid_url);
// sorting done

	$this->tpl->parse("view");
	$out = $this->tpl->text("view");

	lib_output($out, "Manage my Ads");
	exit;

}











// View Advertisers
function advertisers()
{
	global $f;

	if($f[parent] == "")
	{
		if($_SESSION[user][super_admin] == 1)
		{
			$f[parent] = 0;
		}
		else
		{
			$f[parent] = $_SESSION[user][id];
		}
	}


/*
	if($_SESSION[user][super_admin] == 1)
	{
// this was default, for roll back, use the below sql only.
		$sql="SELECT * FROM adrev_users";
	}
	else
	{
		$sql="SELECT * FROM adrev_users where parent=" . $_SESSION[user][id] . " ORDER BY login";
	}
*/

	$sql="SELECT * FROM adrev_users where parent='" . $f[parent] . "' ";

// sorting section ... start
	if(!$f[order_by])
		$f[order_by] = "login";

	if($f[change_order] == 1)
	{
		if($f[asc]=="ASC")
		{
			$f[asc] = "DESC";
		}
		else if($f[asc]=="DESC")
		{
			$f[asc] = "ASC";
		}
	}

	if(!$f[asc])
		$f[asc] = "ASC";


	$sql .= " ORDER BY ".$f[order_by]." " . $f[asc];

	$sort_url_base="/ads/index.php?section=admin&action=advertisers&f[asc]=".$f[asc]."&f[change_order]=1&f[parent]=".$f[parent]."&f[order_by]=";


	$sort_date_url=$sort_url_base."`date`";
	$sort_type_url=$sort_url_base."`super_admin`, `admin`";
	$sort_user_url=$sort_url_base."`name`";
	$sort_login_url=$sort_url_base."`login`";
	$sort_password_url=$sort_url_base."`password`";
	$sort_email_url=$sort_url_base."`email`";
	$sort_ads_url=$sort_url_base."`date`";
	$sort_clicks_url=$sort_url_base."`date`";
	$sort_views_url=$sort_url_base."`date`";
	$sort_spend_url=$sort_url_base."`date`";

// sorting section ... end

// paging section... start

/*
the main variables, with the href part as well are:
$first $previous $current $next $last
*/

// set the page limit
	if(!$f[page_limit])
		$f[page_limit]=20;

// set the current page
	if(!$f[current_page])
		$f[current_page]=1;

// calculate the total page
	if(!$f[total_page])
	{
		$cnt = lib_getsql($sql);
		if(count($cnt) > 0)
		{
			$f[total_page]=ceil( count($cnt) / $f[page_limit] );
		}
	}

// alter the sql now...
	$sql .= " limit " . ( ($f[current_page] - 1)*$f[page_limit] ) . " , " . $f[page_limit];




// construct the url base...
	$url_base="<a href=\"/ads/index.php?section=admin&action=advertisers&f[page_limit]=" . $f[page_limit] . "&f[total_page]=" . $f[total_page] . "&f[order_by]=".$f[order_by]."&f[asc]=".$f[asc]."&f[parent]=".$f[parent]."&f[current_page]=";


	$first=$url_base . 1 ."\">First</a>";

	if(($f[current_page]-1) <= 0)
	{
		$previous=" ";
	}
	else
	{
		$previous=$url_base . ($f[current_page]-1) . "\">Previous</a>";
	}

	$current="Current Page: " . $f[current_page] . "/" . $f[total_page];

	if(($f[current_page]+1) > $f[total_page])
	{
		$next=" ";
	}
	else
	{
		$next=$url_base . ($f[current_page]+1) . "\">Next</a>";
	}

	$last=$url_base . $f[total_page] . "\">Last</a>";

// paging section end



//echo "<br>".$sql."<br>";

// modified by nir
	$u = lib_getsql($sql);
// end of modification




	$clicks = 0;
	$spend = 0;
	$views = 0;
	$ads = 0;
	if(count($u) > 0)
	{
		foreach($u as $rec)
		{
/*
// Grab the stats, there will be two parts...
// part one, we will get the stats of the current loop user...
			$s = lib_getsql("SELECT count(id) as ads, sum(clicks) as tclick, sum(impressions) as tviews, sum(amount) as tamount
									FROM adrev_ads WHERE userid='$rec[id]' GROUP BY userid");
			$stats = $s[0];
// part two, where we fetch the stats of the downline ... in recursive mode... :-)
*/
			$stats=array();
			$stats = recursive_stat_fetch($rec[id],$stats);


			$bgcolor = iif($bgcolor== "#FFFFFF", "#FFFFEE", "#FFFFFF");
			$this->tpl->assign("BGCOLOR", $bgcolor);
			$this->tpl->assign("DATE", $rec[date]);
/*
			if($rec[admin] == 0)
				$this->tpl->assign("TYPE", "Advertiser");
			if($rec[admin] == 1)
				$this->tpl->assign("TYPE", "Admin");
			if($rec[admin] == 2)
				$this->tpl->assign("TYPE", "Sales");
*/
			if($rec[admin] == 0)
				$this->tpl->assign("TYPE", "Advertiser");
			if($rec[admin] == 1)
				$this->tpl->assign("TYPE", "Top Partner");
			if($rec[admin] == 2)
				$this->tpl->assign("TYPE", "Sub Partner");
			if($rec[admin] == 3)
				$this->tpl->assign("TYPE", "Sales Center");
			if($rec[admin] == 4)
				$this->tpl->assign("TYPE", "Sales Person");
			if($rec[super_admin] == 1)
				$this->tpl->assign("TYPE", "Administrator");


			$this->tpl->assign("USERNAME", $rec[name]);

// login link is only available to the super admin
			if($_SESSION[user][super_admin] == 1)
			{
				$this->tpl->assign("LOGIN", "<A href=/index.php?section=user&action=login&f[login]=".$rec[login]."&f[password]=".$rec[password].">".$rec[login]."</a>");
			}
			else
			{
				$this->tpl->assign("LOGIN", $rec[login]);
			}

// done

			$this->tpl->assign("PASSWORD", $rec[password]);
			$this->tpl->assign("EMAIL", $rec[email]);
			$this->tpl->assign("ADS", number_format($stats[ads]));
			$this->tpl->assign("CLICKS", number_format($stats[tclick]));
			$this->tpl->assign("VIEWS", number_format($stats[tviews]));
			$this->tpl->assign("SPEND", number_format($stats[tamount],2));
			$this->tpl->assign("ID", $rec[id]);

// we need to check if the current user has any down line .. the show the plus sign else ... else dont show the plus !
			$dn = lib_getsql("SELECT * FROM adrev_users WHERE parent='".$rec[id]."'");
			if(count($dn) > 0)
			{
				$this->tpl->assign("PLUS", "<a href=\"index.php?section=admin&action=advertisers&f[parent]=".$rec[id]."\"><img src=\"images/plus.jpg\" border=0 height=15 width=15 alt=\"Expand Downline\"></a>");
			}
			else
			{
				$this->tpl->assign("PLUS", " ");
			}
// done



// edit / delete link will be visible to the super user only
			if(($_SESSION[user][admin] == 1) || ($_SESSION[user][admin] == 2) || ($_SESSION[user][admin] == 3) || ($_SESSION[user][admin] == 4) || ($_SESSION[user][super_admin] == 1))
			{
				$this->tpl->assign("EDEL", "<a href=index.php/user/edit_register/".$rec[id].">Edit</a> | <a href=index.php/admin/del_user/".$rec[id].">Delete</a>");
			}
			else
			{
				$this->tpl->assign("EDEL", " ");
			}
// done


// broadcast should be only available to super admin
			if($_SESSION[user][super_admin] == 1)
			{
				$this->tpl->assign("BRODCAST", "» <a href=/index.php/admin/blast>Broadcast an Email Message</a><br> ");
			}
			else
			{
				$this->tpl->assign("BRODCAST", " ");
			}

// done


// for paging
			$this->tpl->assign("FIRST", $first);
			$this->tpl->assign("PREVIOUS", $previous);
			$this->tpl->assign("CURRENT", $current);
			$this->tpl->assign("NEXT", $next);
			$this->tpl->assign("LAST", $last);
// paging done

// for sorting
			$this->tpl->assign("SORT_USER_URL", $sort_user_url);
			$this->tpl->assign("SORT_DATE_URL", $sort_date_url);
			$this->tpl->assign("SORT_TYPE_URL", $sort_type_url);

			$this->tpl->assign("SORT_LOGIN_URL", $sort_login_url);
			$this->tpl->assign("SORT_PASSWORD_URL", $sort_password_url);
			$this->tpl->assign("SORT_EMAIL_URL", $sort_email_url);
			$this->tpl->assign("SORT_ADS_URL", $sort_ads_url);
			$this->tpl->assign("SORT_CLICKS_URL", $sort_clicks_url);
			$this->tpl->assign("SORT_VIEWS_URL", $sort_views_url);
			$this->tpl->assign("SORT_SPEND_URL", $sort_spend_url);
// sorting done


			$this->tpl->parse("users.list");

			$clicks += $stats[tclick];
			$ads    += $stats[ads];
			$views  += $stats[tviews];
			$spend  += $stats[tamount];
		}
	}

	$this->tpl->assign("TADS", number_format($ads));
	$this->tpl->assign("TCLICKS", number_format($clicks));
	$this->tpl->assign("TVIEWS", number_format($views));
	$this->tpl->assign("TSPEND", number_format($spend,2));

	$this->tpl->parse("users");
	$out = $this->tpl->text("users");
	lib_output($out, "Manage Avertisers");
	exit;
}

// View Statistics
function stats()
{

}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/56319-need-help-with-allowing-a-next-link/
Share on other sites

I think I did this for my website. I'm not exactly sure if this is what you want to do. What I did was I had links from one page that linked to a page that was pervious and next to that page. - using php. It was dynamic so a template of that page could be used and the links would be adjusted. Tell me if that's what you want to do... then I can help you.

ok i am creating a drop down field that displays numbers

each number is a link to the next page

 

so when the user selects the number 5 for instance he is taken to page 5

but if the user selects 1 he is taken to page 1

 

i already did most of the work i think i just need help fixing it

add a select box ok

 

<?php 

// Database Connection 
include 'db.php'; 

// If current page number, use it 
// if not, set one! 

if(!isset($_GET['page'])){ 
   $page = 1; 
} else { 
   $page = $_GET['page']; 
} 

// Define the number of results per page 
$max_results = 10; 

// Figure out the limit for the query based 
// on the current page number. 
$from = (($page * $max_results) - $max_results);  

// Perform MySQL query on only the current page number's results 

$sql = mysql_query("SELECT * FROM pages LIMIT $from, $max_results"); 

while($row = mysql_fetch_array($sql)){ 
   // Build your formatted results here. 
   echo $row['title']."<br />"; 
} 

// Figure out the total number of results in DB: 
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM pages"),0); 

// Figure out the total number of pages. Always round up using ceil() 
$total_pages = ceil($total_results / $max_results); 

// Build Page Number Hyperlinks 
echo "<center>Select a Page<br />"; 

// Build Previous Link 
if($page > 1){ 
   $prev = ($page - 1); 
   echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; 
} 

for($i = 1; $i <= $total_pages; $i++){ 
   if(($page) == $i){ 
       echo "$i "; 
       } else { 
           echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; 
   } 
} 

// Build Next Link 
if($page < $total_pages){ 
   $next = ($page + 1); 
   echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; 
} 
echo "</center>"; 
?> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.