Forum Moderators: coopster
Well my logic is that for every link I create a corresponding table in a database...
You should only need one table. If you only need the number of clicks, the table would contain the fields `linkID`, `link_name1 and `clicks`. Then some PHP code like this would update the table:
<?php// Connect to database here
switch ($_GET[linkID])
{
case "1":
mysql_query("UPDATE `tablename` SET `clicks` = `clicks`+1 WHERE `linkID` = $_GET[linkID]");
header("Location: http://www.example.com");
break;
case "2":
mysql_query("UPDATE `tablename` SET `clicks` = `clicks`+1 WHERE `linkID` = $_GET[linkID]");
header("Location: http://www.example.com");
break;
?>
I'm sure that the code can be improved but it should give you an idea of what to so.
$valid_ids = array(1,2,3,4,5,6,7,8,9);
if([url=http://us3.php.net/manual/en/function.in-array.php]in_array[/url]($_GET["linkID"],$valid_ids))
{
mysql_query("UPDATE tablename SET clicks = clicks+1 WHERE linkID = ".$_GET["linkID"]);
}
Good luck!
hard coded:
/////////////////////
$valid_ids = array(1,2,3,4,5,6,7,8,9);
$links = array("link1.html","link2.html","link3.html","link4.html","link5.html,"link6.html","link7.html","link8.html","link9.html");
if(in_array($_GET["linkID"],$valid_ids))
{
mysql_query("UPDATE tablename SET clicks = clicks+1 WHERE linkID = ".$_GET["linkID"]);
header("Location: ".$links[$_GET["linkID"]-1]);
}
/////////////////////
or
through url: example http://www.example.com?linkID=2&url=http://google.com
////////////////////
$valid_ids = array(1,2,3,4,5,6,7,8,9);
if(in_array($_GET["linkID"],$valid_ids))
{
mysql_query("UPDATE tablename SET clicks = clicks+1 WHERE linkID = ".$_GET["linkID"]);
header("Location: ".$_GET["url"]);
}
////////////////////
Good luck ;)
[edited by: jatar_k at 11:32 pm (utc) on June 20, 2006]
[edit reason] examplified [/edit]