Forum Moderators: coopster
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!
- 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
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.