|
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");
?>
|