Hi Guys!
I don't think i'v ever actually posted on this forum before, so i'd like to say Hi to everyone!
I've recently created a Arcade style website (ConcaveGaming) but I seem to be lacking a lot of traffic. Well, I get about 200-300 visits a day. This is a great start, however, I'm looking to expand this up to about 1000 in the next month.
I thought of an idea of getting users to compete in getting the most hits on my website - the person with the most hits at the end of the month would win a prize. Now, I thought i'd be best asking you PHP guys about this, seeing as it's pretty much all I can use..
So what am I looking to achieve?
Firstly, I need to create a PHP file that will update a users hits every time somebody visits.
For example, if somebody visited: "http://www.concavestudios.com/refer.php?username=[COLOR="rgb(255, 0, 255)"]blimp[/COLOR]"
then the PHP file would recognize this and increment the username (Highlighted in pink) by one.
Secondly, it would be nice if the users could check how many hits they have actually got. However, I don't think there is any need for passwords with this.
Would anybody be able to help me, or should i say, practically script this for me? I have no knowledge of PHP whatsoever and don't think it's a great idea to learn, seeing as I already have a lot of programming languages in my tiny head.
Also, if this helps, i'll put my database details down...
host:ConcaveGaming
username:alex
databasename:users
password:password11
And no, that's not my real password;)
Thanks for your help in advance!
Blimp
Random link generator and Hit counter
Started by Blimp, Nov 05 2010 07:12 AM
12 replies to this topic
#1
Posted 05 November 2010 - 07:12 AM
|
|
|
#2
Posted 05 November 2010 - 07:15 AM
Looks like the highlighting didn't work.. Sorry about that guys. Also, I can't seen to edit it.
#3
Posted 05 November 2010 - 07:53 AM
Hello Blimp.
Add another table of type int to your database, name it whatever you like (for example, hits). You can simply use MySql update to insert new value there.
Add another table of type int to your database, name it whatever you like (for example, hits). You can simply use MySql update to insert new value there.
#4
Posted 05 November 2010 - 07:56 AM
I know that. I need to know how to edit the data via PHP.
#5
Posted 05 November 2010 - 08:04 AM
<?php
$conn = mysql_connect("host", "user", "password");
mysql_select_db("database_name") or die(mysql_error());
mysql_query("UPDATE table_name SET hit = '$new_value' WHERE name = '$user';");
mysql_close($conn);
?>
$conn = mysql_connect("host", "user", "password");
mysql_select_db("database_name") or die(mysql_error());
mysql_query("UPDATE table_name SET hit = '$new_value' WHERE name = '$user';");
mysql_close($conn);
?>
#6
Posted 05 November 2010 - 08:08 AM
And what will this do?
#7
Posted 05 November 2010 - 08:10 AM
this code will be part of a page, when user loads it this will update user's hits with new value. new_value = old_value + 1. I hope you know how to get data from MySql.
#8
Posted 05 November 2010 - 08:15 AM
Okay. Well, I'm guessing that using this snippet in my script and replacing the database name,password and table should do the trick?
#9
Posted 05 November 2010 - 08:18 AM
I hope so. If there is something else, I'll try to help you.
#10
Posted 05 November 2010 - 08:26 AM
Thanks. Would you be able to email me on:
admin@concavestudios.com
As i'm not sure how to set up the table properly. thanks!
admin@concavestudios.com
As i'm not sure how to set up the table properly. thanks!
#11
Posted 05 November 2010 - 08:44 AM
You can use phpmyadmin. It is very simple.
#12
Posted 06 November 2010 - 01:47 AM
Actually, the SQL query can be made much easier. This will work :
Quote
UPDATE table_name SET hit = hit+1 WHERE name = '$user';


Sign In
Create Account



Back to top









