PDA

View Full Version : Advertising Script


Eckxmods
01-24-2005, 04:22 PM
Hey guys, I was making an advertising script and I wanted to know a couple of things for it. Note, I am very new to MySQL and am learning as I go so excuse the stupidness.

1) There are 2 ways the advertising can be shown, as standard 468x60 wide banners and 160x600 tall banners. Now the script I have to display the banner uses the ORDER BY RAND() command. Is there a way I can filter out if the banner is a standard or a tall banner?

2) I also want to make a activate, deactivate, expired status. How can I go about making this in MySQL?

Any help would be GREATLY appreciated. Sorry if I have posted some stuff that have already been answered, I tried searching a bit before I posted.

Thanks again guys.

anarchy3200
01-24-2005, 10:24 PM
OK so for this you will need a couple of extra columns in your database.
So an example structure of columns i would use would be:

ID, Link, Size, Active, Expired

So the id would just be a default auto_increment so they all have their own id, this is standard for when you start manipulating the data as they need to have a unique id.
Link would be the link to the advert
Size, i would use this to determin the size of you image, you could either set it to 't' or 'w' to resemble tall or wide and then in your query put in a where statement:

WHERE `Size` = 't'

Which would then filter out any that are of the wrong dimensions.

I would use the active column as just a single integer of 1 or 0, if it is 1 then the image is shown, if it is 0 then the image is not o this would be included into the where:

WHERE `Size` = 't' AND `Active1 = '1'

For the expiry depending on how you want to do this you could either add the expired column and set it to 1 if you do not want the image to display any more:

WHERE `Size` = 't' AND `Active1 = '1' AND `Expired` = '0'

or you could set this as a date, e.g.
expired = 2005/01/24

WHERE `Size` = 't' AND `Active1 = '1' AND `Expired` < 'date(Ymd)'

This would make sure that the date is before the value in the Expired Column


Hope this helps and you have followed what i have said.
Good Luck :p , feel free to ask any more questions

Eckxmods
01-25-2005, 02:00 AM
Thank you very much for the info, I have made the module. Right now it filters if its a tall or a wide banner and shows ads randomly. I also can change the status to active, deactive, and expired on my administration pannel.

The last thing I need to do is make a system that will change the status of the banner to EXPIRED atuomatically. I have made a variable called $impressions which count how many times the banner has been loaded. The variable for the number of impressions the client has ordered is $purchasedimp.

My question is, how do i make the script so that if $impressions > $purchasedimp it changes the status to EXPIRED and shows a different banner. Basically I want the banner to expire after the banner has been showed the number of times the client paid for it to show. I have no idea how to go about this function.

I know that my questions are n00bish to you guys but I started PHP and MySQL just a month ago and this is my first officail project. Thanks again.

Kiwi
01-25-2005, 03:45 AM
Well, you would need to store that data in the database. You need a fields for 'purchasedimp' and 'impressions' linked to the banner's unique ID. When the banner is created, enter the 'purchasedimp' value. Each time the banner is loaded, you increment 'impressions': UPDATE table SET impressions=impressions+1 WHERE id=<selected banner>. Then add a criteria to your banner SELECT ... FROM table as A WHERE A.impressions < A.purchasedimp.