Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4041768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:55:18+00:00 2026-05-20T12:55:18+00:00

I am trying to set up a simple hit counter within expression engine using

  • 0

I am trying to set up a simple hit counter within expression engine using javascript and php. If a user clicks a certain link, I want it to trigger a javascript function which updates a value within my expression engine database. My setup is this:

I have a table called exp_custom_stats. Within that table are several rows of stats. For this example we’ll use stat_downloads as the row that needs updating, with stat_name as the column header for stat_downloads, and stat_count as the column header for the value.

All I want to do is connect to the database, retrieve the stat_count for stat_downloads, and store it as a variable. Then on javascript click of a link, I want to increment that variable by one, and submit it back to the database as an update. The rough example would be below, but how do I connect to the DB in expression engine through a template?

DB Connection:

<?php 
SELECT * FROM exp_custom_stats WHERE stat_name = 'stat_downloads';
$stat_val = 'stat_count';
$stat_val++;
echo "$stat_val";
?>

DB Update:

<script type="text/javascript">
    $(document).ready(function() {
 $('.stat_increment').click(function(){
<?php 
INSERT INTO exp_custom_stats
VALUES ($stat_value)
WHERE stat_name = 'stat_downloads';
?>
 });
    });
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:55:18+00:00Added an answer on May 20, 2026 at 12:55 pm

    I figured out a way to do this using a combination of AJAX, PHP, and the External Entries add-on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to hit a webserver using a simple Socket rather than using
Trying to set up a simple login script in flex 4 with php. In
I'm trying to set up a simple form for a mailing list. And it
I'm trying to write my first small plugin and I've sort of hit a
I've got this problem that It always hit the PropertyAccessException when trying to saveOrUpdate();
I'm using EF4 POCOs and UnitOfWork/repository patterns with MVC 3. I'm trying to understand
I am trying to implement Gmail style drag-and-drop file upload in ASP.NET MVC. I
What I need is to be able to execute code in a code-behind for
I'm working on a pretty tricky problem that I've been on for literally a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.