marksie1988 Posted December 4, 2007 Share Posted December 4, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/80134-solved-ad-management-tutorial/ Share on other sites More sharing options...
pocobueno1388 Posted December 5, 2007 Share Posted December 5, 2007 Store the information either in a database or text file. That way you can keep track of how many times it has been displayed. Quote Link to comment https://forums.phpfreaks.com/topic/80134-solved-ad-management-tutorial/#findComment-406538 Share on other sites More sharing options...
marksie1988 Posted December 5, 2007 Author Share Posted December 5, 2007 yes but i dont want to have to keep on checking up on it though i jst want it to stop by itself Quote Link to comment https://forums.phpfreaks.com/topic/80134-solved-ad-management-tutorial/#findComment-406823 Share on other sites More sharing options...
marksie1988 Posted December 5, 2007 Author Share Posted December 5, 2007 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?? Quote Link to comment https://forums.phpfreaks.com/topic/80134-solved-ad-management-tutorial/#findComment-406859 Share on other sites More sharing options...
pocobueno1388 Posted December 5, 2007 Share Posted December 5, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/80134-solved-ad-management-tutorial/#findComment-406892 Share on other sites More sharing options...
marksie1988 Posted December 5, 2007 Author Share Posted December 5, 2007 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"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/80134-solved-ad-management-tutorial/#findComment-407319 Share on other sites More sharing options...
marksie1988 Posted December 5, 2007 Author Share Posted December 5, 2007 i fixed it now thanx for the mysql statement Quote Link to comment https://forums.phpfreaks.com/topic/80134-solved-ad-management-tutorial/#findComment-407329 Share on other sites More sharing options...
pocobueno1388 Posted December 5, 2007 Share Posted December 5, 2007 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>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/80134-solved-ad-management-tutorial/#findComment-407332 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.