ketting00 — 2013-10-29T04:32:21-04:00 — #1
I have a table of advertisement with expiry date and location. Currently, I display ad at random base on user’s location.
In the near future, I want to add tier system in to my ad sale. It means the first tier ad should be displayed more often than the second tier, but I don’t know how to control that.
Is there any existing solution for my problem?
ketting00 — 2013-11-05T08:33:34-05:00 — #2
Anyone? Here's the code I've been done so far:
Creating a table:
$mysqli->query("CREATE TABLE `ads` (
`id` INT NOT NULL AUTO_INCREMENT,
`uid` INT NOT NULL,
`txt` TEXT NOT NULL,
`date` DATE NOT NULL default '0000-00-00',
`img` VARCHAR( 120 ) NOT NULL,
`location` VARCHAR( 75 ) NOT NULL,
`expiry` DATE NOT NULL default '0000-00-00',
PRIMARY KEY ( `id` ),
) ENGINE = INNODB CHARACTER SET UTF8 COLLATE utf8_general_ci
or die("DB error!");
Random with PHP:
SELECT id, uid, img, location, expiry
WHERE location = '$location' AND CURDATE() < expiry AND RAND()<(SELECT ((1/COUNT(*))*10) FROM ads)
ORDER BY RAND()
Some one suggests I have to add some sort of percentage but I wasn't lucky with Google search.
r937 — 2013-11-05T09:23:14-05:00 — #3
similar thread on (shock!) another forum yesterday...
ketting00 — 2013-11-05T09:41:47-05:00 — #4
Thank you. Any added knowledge is good news. I'm now convinced that it is seriously problematic. I'll abandoned this until getting further information.
Thank you again.
ketting00 — 2013-11-06T05:55:03-05:00 — #5