4) Create a file called
affiliates.php and add this code in:
<?php include "db.php"; ?>
CODE
<?php
include "db.php";
$result = mysql_query("SELECT * FROM affiliates ORDER BY id");
while($row = mysql_fetch_array($result)){
echo "<a href='http://www.domain.com/affiliate_out.php?id=".$row['id']."' target='_blank'>
<img src='".$row['image']."' alt='".$row['name']."' title='".$row['name']."' width=88 height=31 border='0'></a> "; }
$result = mysql_query("SELECT * FROM affiliates");
$num_rows = mysql_num_rows($result);
echo "Total Affiliates: $num_rowsn";
?>
This file shows all the affiliates and how much affiliates there are.
5) Now, create a file called
affiliate_out.php and add this code in there:
CODE
<?php
include "db.php";
if (isset($id)){
$update = mysql_query("UPDATE affiliates SET views = views + 1 WHERE id='$id'");
$result = mysql_query("SELECT link FROM affiliates WHERE id='$id'");
$row = mysql_fetch_array($result);
$afflink = $row['link'];
header("Location: $afflink");
mysql_close();}
?>
NOTE: Make sure that all the database connection files are in reach of the file requesting them. Also, for the administration panel, it is not password protected, so you may have to put it in the directory
http://www.domain.com/admin/ and protect it with .htaccess. If you need help on password protecting the folder, read the tutorial on pd about it!
Thats it! I hope this tutorial has helped you! If you have any questions, feel free to ask and I will try and answer all of the errors/comments/questions that you may have.