Jump to content


Photo

increment by 1 please help cheers.


  • Please log in to reply
10 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 23 July 2006 - 09:21 PM

advance thank you.


high there i am trying to get the $hits to increment by one,

when the page loads the first 1 goes in but then onwards nothink please help cheers.

my code example cheers.

<?

if($_GET['cmd']=="update"){

$query_update="update member_topics set hits=$hits+1 where date_added='".$_GET['date_added']."' and 

time_added='".$_GET['time_added']."' and user_id='".$_GET['user_id']."'";
$result_query=mysql_query($query_update);

echo $query_update;
}
?>


database query result please help
update member_topics set hits=+1 where date_added='23-07-06' and time_added='10:06:14' and user_id='00002'

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 23 July 2006 - 09:29 PM

try hits=hits+1

#3 Joe Haley

Joe Haley
  • Members
  • PipPipPip
  • Advanced Member
  • 103 posts
  • LocationCanada, eh?

Posted 23 July 2006 - 09:30 PM

or place $hits++; on the line before the query.
Give a man a fish; you have fed him for today.  Teach a man to fish; and you have fed him for a lifetime
Don't teach men to program. Teach them to fish.

Please, try the RTFM solution before asking for help:
http://php.net/manual/en/index.php

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 23 July 2006 - 09:41 PM

ok hits=hits+1 worked cheers but as always lol...........

if the user resfresh the page that hit will keep going up any idears cheers php only theo.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 23 July 2006 - 09:56 PM

Bit of clarification, please.

If I 'refresh' page X, you don't want the hits to increase. 

If I visit another page on the site and then navigate back to page X, should hits increment?

If I leave your site and come back later to page X, should hits increment? 

If I was away for an hour, or away for a week, would it matter in your answer to my last question.
Legend has it that reading the manual never killed anyone.
My site

#6 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 23 July 2006 - 09:58 PM

ok hits=hits+1 worked cheers but as always lol...........

if the user resfresh the page that hit will keep going up any idears cheers php only theo.


Duh...  ??? Ofcourse it does. To avoid that you'll have to link the view of a page to the client.

Possible solutions:
1) link the hit to the sessionid or even stored username/id
2) link the hit to a client with a cookie
3) link the hit to a client by ip

Take your pick.

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 23 July 2006 - 10:04 PM

andy was going to use sleep() or set_time_limit()

but the problam is that i wanted to add a function that a user can not refresh the same page.

so that the hits dont increment on a page that there viewing but the page is also the page that they will view other topics.

example a user goto a topic they like the user press the refresh button the user gets a echoed message from that viwing page and database entry.

i thort that i get the users ip while on the page of viewing then let them sleep or echo a message what do youthink works better.


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 23 July 2006 - 10:12 PM

i want to get the user ip

user=$_SERVER['REMOTE_ADDR'];

if the user refresh

send them to the home page.

header("location: index.php");


what i need to know how wili now the user has press refresh.


example only


<?

$user_ip=$_SERVER['REMOTE_ADDR'];

$kept_session=$_SESSION['kept']=$user_ip

if($user_ip == $kept_session ) {

header("location: index.php")

}

?>







Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 23 July 2006 - 10:23 PM

solved

when the user press the button the link will send them to a update page then rediret to the topic there viewing cheers.


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 23 July 2006 - 10:33 PM

I, like Andy, am still a bit confused at what exactly your goal is. But I'm assuming you want to link the page view to the clients' ip...
There's a reason it's the third option and not the first or second, but nevermind.

Let's focus on what YOU want to do (if I understand correctly):

Store the pages a specific ip has already visited, so count won't increase on second visit.

How? Store the data linking an url to several ip's.

Example:
INSERT INTO hits (url,ip) VALUES (**,**)

Include an UNIQUE index on the ip column. Inserting the same ip twice will fail. Add a TIMESTAMP column for garbage collection purposes.

To get the full hit count:
SELECT count(ip) FROM hits WHERE url = *

EDIT:
Pfff... This is getting obnoxious.

#11 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 24 July 2006 - 04:14 AM

this was solved but cheers anyway lol...........................
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users