Forum Moderators: coopster

Message Too Old, No Replies

Getting mypage.php?action=$row_table['hits']

         

msmtrimm

6:09 pm on Aug 13, 2004 (gmt 0)

10+ Year Member



How would I go about doing that, I have an Idea, but I am only confusing myself.

mypage.php?action=$row_table['hits']

I have the code here....

<?
include('../Connections/chamber.php');

$query = "SELECT id,hits FROM affiliates";

if($action_add == $row_query['id'];){
$add = "INSERT INTO hits FROM affiliates WHERE id='$row_id['id']' VALUES ('+1')";
while(mysql_fetch_array($add){
header(Location: 'index.php');
}
}
?>

^^ That is a part of my affiliates code I am working on, how would I get it to work? Please, I would like to know. Thanks!

ergophobe

8:20 pm on Aug 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You are missing several steps. You need to

- build a query (OK)
- send the query to the DB server (missing)
- retrieve the results of the query (missing)
- apply those results to what you want

A few things to note.

1. When getting data, I need to send the query, then process the result set in a while loop.

2. You can't have a WHERE clause in an insert, because the row does not yet exist. If you are changing the value of a row, you need to UPDATE

3. You can't use mysql_fetch_array on an insert query, because INSERT does not return a result set.

As for the specifics of your script, I don't understand what you're trying to achieve, so I can't really help, but a careful reading of
this thread [webmasterworld.com] and this one [webmasterworld.com] and message 9 of this one [webmasterworld.com] might put you on the road to success.

Tom

msmtrimm

8:43 pm on Aug 13, 2004 (gmt 0)

10+ Year Member



What I am trying to make is an Affiliates System... Just where sites can sign up and battle it out for number 1. How they get number one is by getting hits. The hits will then add up.... but I am stuck on getting the hits to add....

So say if The Snitch.co.uk wanted to affiliate with us. Their affiliate id was 327. To add a hit to their name, they would simply go to affiliates.php?add=327 and their hit would be added.

Hopefully that explains what I want to do.

coopster

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

WebmasterWorld Administrator 10+ Year Member



OK, now start with ergophobe's direction. First, you need to build the query. What you want to do is INSERT a new row for that site, unless it already exists, then you will want to UPDATE it, correct?