Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

increment by 1 please help cheers.

Recommended Posts

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.

[code]
<?

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;
}
?>

[/code]

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote author=redarrow link=topic=101591.msg402187#msg402187 date=1153690860]
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.
[/quote]

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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")

}

?>






Share this post


Link to post
Share on other sites
solved

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
this was solved but cheers anyway lol...........................

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.