• Well, i read somewere that there already is one, and that sucks. But well, i’ve had fun making it, and I just wanted to show it here. It’s xl simple, because you just have to add this within ,,the loop”:
    <?php views() ?>
    It genrates a new row in the database automatically. Yes i know, you’re all asthonised by this wonderfull plugin …
    If i’m online my sever is also, you can find the stuff here and here.
    When i’m not online:
    <?php
    /*
    Plugin Name: PPP (Pageviews Per Post)
    Plugin URI: https://schot.xs4all.nl/index.php?p=3
    Description: Pageview counter for posts, automatic. My site is online, when i'm online ;)
    Version: .01b
    Author: jmschot
    Author URI: https://schot.xs4all.nl
    */

    function views() {
    $count_id = $_GET['p'];
    if ($count_id == NULL) {
    global $id;
    $result = mysql_query("
    select *
    from wp_count
    where count_id='".$id."'");
    $r=mysql_fetch_array($result);
    echo $r[count] . " pageviews";
    return;
    }
    $result = mysql_query("
    select *
    from wp_count
    where count_id='".$count_id."'");
    $r = mysql_fetch_array($result);
    if ($r[count] == NULL) {
    $create = mysql_query("
    insert into wp_count
    (count, count_id)".
    "VALUES (1, '$count_id')");
    $pageviews = "1";
    }
    else {
    $update = mysql_query("
    update wp_count
    set count = count+1
    where count_id='".$count_id."'");
    $pageviews = $r[count]+1;
    }
    echo $pageviews . " pageviews";
    }
    ?>
    CREATE TABLE ‘wp_count’ (
    ‘count’ varchar(255) NOT NULL default ”,
    ‘count_id’ varchar(25) NOT NULL default ”
    ) TYPE=MyISAM
    Later

Viewing 15 replies - 1 through 15 (of 20 total)
  • Hi jmschot,
    I didn’t know of any plugin like yours. Does it count views by unique readers, or does it count views by the same reader as different views? I would love to have views by unique readers (uinque IPs), that gives a better idea of how many people read a post.
    Thanks,
    Eduardo

    Thread Starter jmschot

    (@jmschot)

    Heey anatman,
    Well, it doesn’t do that now, but i could do that if you like, it’s not really much work.
    Check back later this day ??

    Thanks jmschot, i didn’t find you online, so i’m emailing you now!

    I’m having a challenge getting pageviews to work. I’ve modified my mySQL database to create the wp_count table with the 2 fields.
    In my index.php page, I call the pageviews script, like so:
    require_once(‘plugins/pageviews.php’);
    In my index.php page, I’ve modified the 2nd line of the post metadata so that it adds the # pageviews after the date and time, like so:
    <div class=”meta”>Filed under: <?php the_category() ?> — <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(); ?> <?php views(); ?></div>
    Now when I load my website, I get some text like this:
    Filed under: wordpress a€?? midtoad @ 16:27:49 MDT pageviews
    Since the word pageview is printed, I can see that the pageviews.php has been found and processed. However, there is no number of views printed. Upon closer examination of the pageviews script, I don’t see anywhere where a database connection is made, so it’s possible that no number is printed because none is fetched! How do I ensure that I get a db connection with this script?
    thanks

    Thread Starter jmschot

    (@jmschot)

    1) anatman, i emailed you
    2) midtoad, you must put the script into your plugins dir in wp-content … then you get the db connection

    jmschot, my index.php is in a directory /wp/ . If I understand you correctly, this would be my wp-content dir. I’ve created a plugins dir off that and put the pageviews script in there – no go.
    have I got it in the right place? thanks.

    Thanks jmschot, i got it and will install the plugin as soon as i upgrade my WP to 1.2. Just waiting for the beta cycle to finish so i install the final.

    Thread Starter jmschot

    (@jmschot)

    Midtoad, nope you didn’t understand me correctly … If you’re running 1.2, there is a directory called wp-content. In that directory there is a dir called plugins. Drop the stats.php file there. Then go to your website, login to wp, and go to the plugins. There, activate the plugin. Then just add the function <? views(); ?> anywhere within ,,the loop” and everything will work correctly. If you don’t have 1.2, you’ll have to create the file my-hacks.php in the same dir were your index.php is. Then just add the <? views(); ?> inside ,,the loop”.
    Hope this helps …

    Thread Starter jmschot

    (@jmschot)

    Well, my site is still doing funky, but i think this should work:
    https://schot.xs4all.nl/plugs.php
    If it doesnt, well, shit.

    Error
    SQL-query :
    CREATE TABLE ‘wp_count'(
    ‘count’varchar( 255 ) NOT NULL default ”,
    ‘count_id’varchar( 25 ) NOT NULL default ”
    ) TYPE MYISAM
    MySQL said:
    #1064 – You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ”wp_count'( ‘count’varchar( 255 ) NOT NULL default ”,
    ‘c

    @haasim: you are missing spaces. replace ‘count’varchar with ‘count’ varchar. Or use phpMyAdmin and use it to create the new table. That’s what I did.
    @jmschot: now I understand what you mean. Since I’m running v.1.0.2, I don’t have the same dir structure as you did. Got it working anyway! ??

    re: midtoad’s reply
    I believe I used the appropriate spaces… I copied the original parameters posted within this thread.
    I’m not really familiar with SQL databases, but I inputed the parameters into a box labeled ‘Run SQL query/queries on database’ and it gave me the error message shown in my previous posting.
    I’m not really sure how to proceed.

    Thread Starter jmschot

    (@jmschot)

    re: haasim
    there are some things wrong with the query in your first reply, but if you use the stats_02.sql from my site, and just drop in the box where you previosly droped it, it really should work.

    Thread Starter jmschot

    (@jmschot)

    *Bump* ??
    Well if you haven’t noticed yet, i’m really busy with this thingy. Anyway, there is a new version out, which can be used for both unique and non-unique counting. It’s also slightly faster, but i’m still working on that. So it’s a BETA (i’ve always wanted to say something like that). New version is going to take a bit longer, because monday it’s back to school again …
    https://schot.xs4all.nl/plugs.php
    look at https://schot.xs4all.nl for more info, and to leave a note if you’re going to use it.

    Thread Starter jmschot

    (@jmschot)

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Pageviews Plugin (ready)’ is closed to new replies.