我想知道如何修改此现有代码以跟踪图像/横幅点击/查看?这甚至可以仅使用 PHP 还是您需要使用 jQuery (ajax)?
我的 MYSQL 表中有bannerClicks
和bannerViews
里面tblbanners
。
这是生成图像/横幅的代码:
$query91 = 'SELECT * FROM tblbanners WHERE tblbanners.bannerStatus!=\'1\'';
$result91 = full_query ($query91);
$bannerCounter = 1;
while ($data91 = mysql_fetch_array ($result91))
{
$ID = $data91['ID'];
$bannerName = $data91['bannerName'];
$bannerLocation = $data91['bannerLocation'];
$bannerUrl = $data91['bannerUrl'];
$bannerCode[$bannerCounter] = '<a id="' . $ID . '" class="banner-url" href="' . $bannerUrl . '" target="_blank"><img alt="' . $bannerName . '" src="banners/' . $bannerLocation . '" width="100px" height="200px" /></a>';
$bannerCounter++;
}
$bannerAdTotals = $bannerCounter - 1;
if($bannerAdTotals > 1)
{
mt_srand((double)microtime() * 1234567);
$bannerPicked = mt_rand(1, $bannerAdTotals);
}
else
{
$bannerPicked = 1;
}
$bannerAd = $bannerCode[$bannerPicked];
print $bannerAd;