Weighted Banner Rotating System with PHP (Web Page Editing and Hosting) - TACKtech Corp.
For the PHP people out there I converted the ColdFusion weighted rotating banner system. It is two files. Here is the first. I called it banner.php. You can call this file from a SSI include and it will run. The PHP and ColdFusion versions both do exactly the same thing in the same way just written for the different languages. Your database needs to be designed
like so.
<?php
@ $db = mysql_connect("<--localhost-->", "<--username-->","<--password-->");
if (!$db)
{ echo "Error: Could not connect to DB.";
$results = mysql_db_query ($dbname,$query,$db);
$magicnumb = rand(0, count($prodlist)-1);
$results2 = mysql_db_query ($dbname,$query2,$db);
mysql_db_query ($dbname,$query3,$db);
print "<A HREF="banner/redirect.php?id=$magicnum" TARGET="_blank">";
?>
The second file I called redirect.php. This page will add 1 to the click value for the banner in the database and then redirect to that site.
<?php
@ $db = mysql_connect("localhost", "<--username-->","<--password-->");
if (!$db)
{ echo "Error: Could not connect to DB.";
$results = mysql_db_query ($dbname,$query,$db);
mysql_db_query ($dbname,$query2,$db);
?>
Comments for this entry:
Comment this entry
Attention: guestbook entries on this weblog have to be approved by the weblog\s owner.
