Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

US Job listings




   Misc

   Amazon

   Links

    


Clickbank affiliate link generator (part 2)
 

 

 

OK if you have survived so far we will look at the 2 scripts that are required to display the links on the page

The first script contains our variables , these include server name , username and password. You will have to set these to your own settings. Also you will have to change the partnerid variable to whatever your clickbank id is . You can get a clickbank id by signing up for free here.

This script is called clickbankinc.php

<?php
//variables
$server = "localhost";
$user = "username here";
$password = "password here";
$database = "database in here";
$tablename = "links";

//queries , connections to the MySQL database
$connection = mysql_connect("$server","$user","$password");
$db = mysql_select_db("$database",$connection);
//display all links uncomment if you require this
//$sql = "SELECT * FROM links";
//display 3 random links
$sql = "SELECT * FROM links ORDER BY RAND() LIMIT 3";
$result = mysql_query($sql,$connection);
$numrows = mysql_num_rows($result);

//html output related
$clickbanktxt = "http://hop.clickbank.net/?";
$partnerid = "shedboy/";
$target = "_blank";
?>

Now lets see the script that displays the links on your page , mainly error handling and HTML output here. This script is called clickbank.php

<?php
include("clickbankinc.php");
//error message for connection
if(!connection)
{
echo "sorry cannot connect to MySQL server just now";
exit;
}
//error message for database
if(!db)
{
echo "cannot connect to the $database database";
exit;
}
//no results returned
if($numrows = 0)
{
echo "no information returned";
exit;
}
echo ("<table>");
while($row = mysql_fetch_array($result))
{
echo "<a href='$clickbanktxt$partnerid$row[1]'>$row[2]</a><p>";
}
echo ("</table>");
mysql_close($connection);
?>

To add the links to your web page just add the following where you would like the lnks to appear

<?php include("clickbank.php"); ?>


 

 

 

 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
Fading text(Javascript)
font exists(VB)
Pop up window(Javascript)
Count the occurences of a SubSTring(VB.net)
Date/Time examples(PHP)
calculate someones age(VB)
Shutdown Windows(VB)
Folder size(ASP)

    




Copyright © 2003 by programmershelp.co.uk