Forum Moderators: coopster

Message Too Old, No Replies

Affiliates Code

         

msmtrimm

5:54 pm on Aug 13, 2004 (gmt 0)

10+ Year Member



I am working on an Affiliates Code for my website, and I am having a problem. I do not know how to get the ranking to rely on the number of hits and display the site with the most hits. Like so, I have set up a testing site button url and that type of stuff. I go into phpmyadmin and edit the number of hits, obviously nothing will change due to it is the only one in there, however I added another icon, same stats and only with a differnet buttonURL. Then I have changed the first on to 50 hits and the second one to 1 hit. Still is the same however when I boost the button with 1 hit, it stays were it is. I cannot figure out how to get it to work. Can you help me out.

coopster

4:09 am on Aug 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you saying you are having difficulty incrementing the *hit count* in your database?

msmtrimm

10:19 pm on Aug 15, 2004 (gmt 0)

10+ Year Member



yes, that is exactly what my problem is with the code.

coopster

10:52 pm on Aug 15, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You need to determine whether or not the site exists in the database, then either INSERT or UPDATE the row accordingly.

msmtrimm

12:43 am on Aug 16, 2004 (gmt 0)

10+ Year Member



Yes it has a database, I need to make sure that when the page is view.... ie add.php?id=345 => then 1 hit is added.

coopster

2:04 am on Aug 16, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I meant table, you need to check and see if the site exists in the table. If not, INSERT the new row, otherwise UPDATE the existing row (if that is indeed how you are managing the table).
// First, get the id from the GET query string: 
$id = (isset($_GET['id'])) ? $_GET['id'] : '';
if ($id) {
$sql = "INSERT INTO table (id) VALUES($id)";
execute query...
if (insert operation fails because of duplicate key...) {
$sql = "UPDATE table SET counter = counter + 1 WHERE id = $id";
execute query...
More error checking here...
}
}