Here is the code im working with now to give you an idea
Code: Select all
<?
include_once ("config.php");
//Find current position in rotator
$result = mysql_query("SELECT * FROM position WHERE num = '1' ");
while($myrow = mysql_fetch_assoc($result))
{
//now print the results:
$position= $myrowї'position'];
$total_count= $myrowї'count'];
$total_links= $myrowї'total_links'];
}
//determine wether or not to start rotator over
if ($position > $total_links){
$query = "UPDATE `position` SET `position` = '1' WHERE `num` = '1' ";
$result = mysql_query($query) or die("error: " . mysql_error());
$position = "1";
} else {
};
//pull link from database
$result = mysql_query("SELECT * FROM links WHERE id = "$position" ");
while($myrow = mysql_fetch_assoc($result))
{
//now print the results:
$id= $myrowї'id'];
$url= $myrowї'url'];
$count= $myrowї'count'];
}
// record hit to url
$new_hit = $count+1;
$query = "UPDATE `links` SET `count` = $new_hit WHERE id = "$position" ";
$result = mysql_query($query) or die ("error: " . mysql_error());
// record hit to total hits in position table
$new_total = $total_count+1;
$query = "UPDATE `position` SET `count` = $new_total ";
$result = mysql_query($query) or die ("error: " . mysql_error());
// add to position number so that it will rotate to the next url
$new_position = $position+1;
$query = "UPDATE `position` SET `position` = $new_position ";
$result = mysql_query($query) or die ("error: " . mysql_error());
// Display url
?>
<html>
<head>
<meta http-equiv="refresh" content="0;url=<? echo $url; ?>">
</head>
</html>