The following tutorial shows you how to make an affiliation system for you, or your admins/moderators, to add affiliate dynamically through a database
1. Make a database connection page. If you do now know how to, there is a tutorial in the php section.
2. Run the following query in your phpmyadmin on the database you are connecting to.
| CREATE TABLE 'affiliate' (
'id' int(11) NOT NULL auto_increment,
'link' varchar(255) NOT NULL default '',
'name' varchar(255) NOT NULL default '',
PRIMARY KEY ('id')
) TYPE=MyISAM AUTO_INCREMENT=3 ;
3. Now to make your admin bit, so you can add affiliates to your table.
Name this file add.php
| <form name="affiliateadd" action="affiliateadd.php" method="POST">
<input name="name" type="text" id="name" style="border: 1px solid #000000; background: #f8f8f8; font-size: 10px; font-family: Tahoma;"><br>
<input name="url" type="text" id="url" style="bored: 1px solid #000000;
background: #f8f8f8; font-size; 10px font-family: Tahoma;"><br>
<input type="submit" value="Submit" style="border: 1px solid #000000; background: #f8f8f8; font-size: 10px; font-family: Tahoma;">
4. Now to make the process for that, so it actually adds the data, rather than redirecting to an empty page that does nothing... Please also change "connect.php" to your connection page. Save this as affiliateadd.php
$name = $_POST['name'];
$url = $_POST['url'];
$sql = "INSERT INTO affiliate (id, name, link) VALUES ('NULL',
$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
echo "Affiliate Added, They will now appear on the affiliate box. Please alert Fin if you f#!*ed up with something. ";
5. Now all we need to do is display your affiliates. This is just a simple query that takes the data from your table.
Save this as whatever you want, it doesnt really matter, but it displays your affiliates. Please remember to edit the connect.php to your connection page again.
$query = "SELECT * FROM affiliate";
$result = mysql_query($query) or die('Error, query failed');
while ($row = mysql_fetch_array($result))
echo "<a href='".$row['link']."'>".$row['name']."</a><br>";
6. Thats all done, now just add affiliates to your hearts content. I might write another tutorial soon on having images in your affiliates system.