GFXVoid Graphic Design Forum

Remove Text Formatting
Loading...

» Online Users: 739

0 members and 739 guests
No Members online

» Site Navigation

 > FAQ

» Stats

Members: 35,443
Threads: 103,072
Posts: 826,684
Top Poster: cc.RadillacVIII (7,429)
Welcome to our newest member, Lekelindids
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2004
    Location
    Buffalo Grove, Illinois
    Posts
    350

    Default

    Use the following PHP tutorial to help you create a hit tracker.

    Insert Into Mysql Database
    Code:
    CREATE TABLE `mini_hits` (
    	`hits` int(10) NOT NULL default'0'
    );
    INSERT INTO `mini_hits` (hits) VALUES ('hits');
    tonfig.php
    Code:
    <?php
    
    $config = array(
    
    //Mysql Settings
    'dbHost' => 'localhost',
    'dbName' => '',
    'dbUser' => '',
    'dbPass' => '',
    
    );
    
    ?>
    counter.php
    Code:
    <?php
    
    include("config.php");
    
    //Connect To Mysql
    mysql_connect($config[dbHost],$config[dbUser],$config[dbPass]);
    mysql_select_db($config[dbName]);
    
    //Count Hits
    $result = mysql_query("SELECT * FROM `mini_hits`");
    $row = mysql_fetch_array($result);
    $row[hits]++;
    $update = mysql_query("UPDATE `mini_hits` SET `hits`='$row[hits]'");
    echo "Total Hits: $row[hits]";
    
    ?>
    Example Here

    Brought To You By PHPMini

  2. #2
    Join Date
    Mar 2005
    Location
    Stockholm, Sweden
    Posts
    156

    Default

    Wow, that surely sucked..

    What's with the SELECT * querys?

    you know what all the columns are named. select * will force mysql to make an extra query, just to find out what the columns are named..

    Just use SELECT hits FROM blabla..

    Also, instead of grabbing the amount of hits, letting php add one to it, just do UPDATE mini_hits SET hits = hits + 1
    http://peksa.se - photos by me.

Similar Threads

  1. Spartan - Total Warrior
    By keden in forum The Void
    Replies: 1
    Last Post: 01-29-2006, 11:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBadvanced CMPS v4.1.1