Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.