I actually have two questions, the first longer than the second. Anyway, I have a site where there is two ad spaces. A Banner and Skyscraper. What I have done is create two tables clients and adSales with a ClientID in each which reference each other user a clientID #. Anyway, for example for the skyscraper space I have the statement as below:
$sql = "SELECT *
FROM AdSales,AdClient
WHERE ADKey = '$ADKey' AND ADType = 'Skyscraper'
";
$result = @($sql,$connection);
while ($row = mysql_fetch_array($result)) {
$ADID = $row['ADID'];
$ADClientID = $row['ADClientID'];
$ADBeginDate = $row['ADBeginDate'];
$ADEndDate = $row['ADEndDate'];
$ADKey = $row['ADKey'];
$ADType = $row['ADType'];
$ADImage = $row['ADImage'];
$AdClientID = $row['AdClientID'];
$AdClientWeb = $row['AdClientWeb'];
}
?>
<? if ($AdClientWeb == "") {
echo ("<img src=\"../ads/$ADImage\" border=0>");
} else {
echo ("<a href=\"http://$AdClientWeb\" target=\"_blank\"><img src=\"../ads/$ADImage\" border=0></a>");
}
?>
No what I am doing is on a specific page chi_index I want the correct ad to come up which with this works fine, but then what I want is once it gets the ad, then I want to attach the URL so someone can click on the ad.
Now, I could just put a field in the AdSales table and that probably would solve the problem, but what I wanted to try to do is match the ad with the client and then get the web url from the client table.
Does this make sense? if not I can surely add more details.
The second question is:
Usually I pass variables between pages like index.php?PageID=chi_index. Now this seems to work, but when I need to use the chi_index in various locations within the page, it doesn't seem to be able to work, such as in the example above, I was trying to do a WHERE statement like
WHERE ADKey = '$PageID' but it doesn't work once a prior statement calls the PageID. like if I do
WHERE PageID = '$PageID' AND ADKey = '$PageID'
What I am trying to do is match the PageID and the ADKey so it pulls the right ad.
Ok, I think I am getting a little confusing so I will submit and clearify with your questions.
Thanks in advance for any help.
Brett