Jump to content

Archived

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

marksie1988

[SOLVED] ad management tutorial

Recommended Posts

i want to create an ad management system so that i can put advertisements on my website but i want the customer to pay for so many shows on the site e.g. after it has been shown X amount of times it wont get shown again

 

is this possible?

Share this post


Link to post
Share on other sites

Store the information either in a database or text file. That way you can keep track of how many times it has been displayed.

Share this post


Link to post
Share on other sites

yes but i dont want to have to keep on checking up on it though i jst want it to stop by itself

Share this post


Link to post
Share on other sites

ok so i have decided that if i create a table with the followint fields

 

id

customer = customers name

www = url for customer website

img = url for customer banner

shown = how many times it has been shown

show = how many times to be shown

 

then i will pull the information from the database and have an if statement as follows

 

if (show == shown ){

retry for another banner

}

 

 

but what i dont know is how can i tell it to try a different banner if the banner has reached its limit??

Share this post


Link to post
Share on other sites

Do a query like this

SELECT img FROM table WHERE shown < show ORDER BY rand()

 

That will ONLY select banners that can still be shown. Then after you show the banner, you can do an update query to update the 'shown' field by one.

Share this post


Link to post
Share on other sites

ok now i have the folowing code which works great but for some reason just keeps on echoing the data i also tried print and the same happened

 

<?php 
$query = "SELECT * FROM `adsys_banner` WHERE `shown` < `show` ORDER BY RAND() LIMIT 1";
$result = mysql_query ($query);
$num = mysql_num_rows($result);

$i=0;
while ($i < $num) {

$id = mysql_result($result,$i,"id");
$cust = mysql_result($result,$i,"cust");
$show = mysql_result($result,$i,"show");
$shown = mysql_result($result,$i,"shown");
$www = mysql_result($result,$i,"www");


echo "$www"; 
}
?>

Share this post


Link to post
Share on other sites

EDIT: Wow, you beat me by fractions of a second, haha

 

It's because your using a while looop. Do this

 

<?php 
$query = "SELECT www FROM `adsys_banner` WHERE `shown` < `show` ORDER BY RAND() LIMIT 1";
$result = mysql_query ($query);
$row = mysql_fetch_assoc($result);

echo $row['www'].'<br>'; 

?>

Share this post


Link to post
Share on other sites

×
×
  • 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.