Jump to content

[SOLVED] hit counter


squiblo

Recommended Posts

this code enters the hit count into the whole field in my database but i just want it to be entered into a specific row of a user how can i do this?

 

<?php
session_start();
?>

<?php
// Connects to your Database
mysql_connect("***", "***", "***") or die(mysql_error());
mysql_select_db("***") or die(mysql_error());

//Adds one to the counter
mysql_query("UPDATE members SET counter = counter + 1");

//Retreives the current count
$count = mysql_fetch_row(mysql_query("SELECT counter FROM members"));

//Displays the count on your site
print "Total hits = $count[0]";


?> 

Link to comment
https://forums.phpfreaks.com/topic/171071-solved-hit-counter/
Share on other sites

I'm assuming you've set up your users table with an ID column, if so

 

mysql_query("UPDATE members SET counter = counter + 1 WHERE user_id = '12345'");

 

Where user_id is the column name containing the ID, and 12345 is the ID.

 

If you don't have an ID column,

 

mysql_query("UPDATE members SET counter = counter + 1 WHERE username = 'bob'");

 

Where username is the column name containing the username, and bob is the name.

 

See MySQL: 12.2.11. UPDATE Syntax for more information.

 

Link to comment
https://forums.phpfreaks.com/topic/171071-solved-hit-counter/#findComment-902212
Share on other sites

Archived

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

×
×
  • Create New...

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.