Hi,
Im creating a simple ad rotator script for my site and would like to add the option of showing the ad only on a specific page.
I have this code that gets the page section:
so .com/a-site-sectionname becomes sectionname
$get_section = explode("/", $_SERVER['REQUEST_URI']);
list($nil, $nil, $section) = explode("-", $get_section[1]);
The javascript to call the ads is:
getBanner.php?type=4§ion=<?php echo $section;?>
then i have this in my javascript code:
if (isset($_GET['show'])){
$total = $_GET['show'];
} else {
$total ="1";
}
$result_banner = mysql_query("
SELECT *
FROM rw_ads
WHERE rw_ads.a_type = '".$_GET['type']."'
AND rw_ads.a_active = '1'
AND (rw_ads.a_section IS NULL OR (rw_ads.a_section = '".$_GET['section']."' OR rw_ads.a_section IS NULL))
ORDER BY RAND()
LIMIT ".$total."
") or die(mysql_error());
$row_banner = mysql_fetch_array( $result_banner );
So basically:
ad_id | section
1 | NULL
2 | section1
3 | NULL
4 | NULL
5 | section2
if i go to section 1, ads 1,2,3,4 would show. If i went to section 2, ads 1,3,4,5 would show.
Thanks in advance for the help!