Question : builing a basic Advertise with Us Functionality!

Hi I am building just a basic Advertise with Us functionality, My client does not want it like a PPC, but a basic one like where he can opt the end users/ markerts to fill a form and submit their logo and other affiliate code to us and pay a fee of 5 USd for 6 months and after 6 months it should be disabled and enabled only on request!

Well can any one guide me here because the way i go like a PPC it has tons of things to dig around like Impressions and Credits and Lots more!

any custom code in any other language would also be helpful so i can have a idea

Answer : builing a basic Advertise with Us Functionality!

Yes, will you need to display the banners in a random fashion to give an opportunity to each of those advertisers. Of course, this will be completely random.

Let's say you have 1 big ad block at the bottom of the website & you are trying to display the ad in that block. If you want to provide an equal opportunity to show all banners, then consider following this:
1. Create one more table, call it: ads_track
2. Now when your client approves ads, they get approved. You will have a ad_id. You will want to consider using this highly to be able to show ads.
3. So say when a visitor visits your page for first time, then show him ad first. Then store the ad_id in a SESSION variable called $_SESSION['ad_id']. Now next time when you are querying, get the id of the ad which is greater than this ad_id. If an ad exists, then you may proceed, if not, the ad_id can be reset to start from the beginning of the table.

I am attaching the code that you would need for this purpose. It's highly commented as well, so you can't miss anything. This will let you provide an equal opportunity to show all ads. Using random can also be a solution, but you won't know how many times an ad is being shown repetitively. At least using the way I explained, you will know that the visitor gets to see the next ad on each page visit.

Does that help?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
<?php session_start();

//Check if the session is set. If not, this means visitor is most likey a new one or session expired.
if( !isset($_SESSION['ad_id']) )
{
	//Try to get ad details of the very first ad
	$result = mysql_query("SELECT ad_id, ad_title, ad_image FROM ads WHERE is_enabled = 1 ORDER BY ad_id ASC LIMIT 1");	
	$num_rows = mysql_num_rows($result);
	
	if( $num_rows == 0 )
	{
		//No ads. You can't display ads if you don't have them. Can you???
	}
	else
	{
		//Oh yes, ad is present. So get it's details & store it's id in session var.
		$row = mysql_fetch_array($result);
		$_SESSION['ad_id'] = $row['ad_id'];
	}
}
elseif( isset($_SESSION['ad_id']) )
{
	//Because the session ad_id exists, we try to get the ad information of the next ad which is present in our ads table.
	$result = mysql_query("SELECT ad_id, ad_title, ad_image FROM ads 
							WHERE is_enabled = 1 AND ad_id > ".$_SESSION['ad_id']."  LIMIT 1");	
							
	$num_rows = mysql_num_rows($result);
	
	if( $num_rows == 0 )
	{
		//No ads. greater than the ad_id. It's possible that there are no more ads after this. So start from beginning of ads table
		$result = mysql_query("SELECT ad_id, ad_title, ad_image FROM ads WHERE is_enabled = 1 ORDER BY ad_id ASC LIMIT 1");	
		$num_rows = mysql_num_rows($result);
	
		if( $num_rows == 0 )
		{
			//No ads. Add some, stranger!
		}
		else
		{
			//If ad is present, then process it.
			$row = mysql_fetch_array($result);
			$_SESSION['ad_id'] = $row['ad_id'];
		}
	}
	else
	{		
		//If ad is present, then process it & store the id in session.
		$row = mysql_fetch_array($result);
		$_SESSION['ad_id'] = $row['ad_id'];
	}
}

?>
Random Solutions  
 
programming4us programming4us