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

  • SEARCH
  • Home
  • 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 3349662
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:41:32+00:00 2026-05-18T01:41:32+00:00

I’m looking for any direction on a really quick and dirty webpage. I’m going

  • 0

I’m looking for any direction on a really quick and dirty webpage. I’m going to have two static items, say person A and person B. I would like to click a (+) or (-) button next to each of them which then increments or decrements an integer that’s displayed relative to each person.

Anyone having a quick tut or anything would be useful.

Aside from this, how hard would it be to keep a viewable log of each time the value was altered either incremented or decremented, would it be easy to add in date/time to that?

Edit

Alright, concerning mysql. I have a db already setup from a previous wordpress installation. I’m going to create a new tables named ‘points’, should this have 2 fields? One for a person A and one for a person B?

  • 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-18T01:41:32+00:00Added an answer on May 18, 2026 at 1:41 am

    Since you want it to remember the value between sessions (ie- if I incremented the counter, left the website, and came back, I expect it to still be incremented) you need to store the value server-side. Databases are the best recommendation for this.

    If you’re planning to use PHP (which I assume from the tags), then MySQL is one of the easiest databases to implement. If you already have a MySQL database set up at your host, then this will be easy. If not, how to set up a MySQL database will be another question you need to ask.

    Since you want quick and dirty the best method would be a form. Either POST or GET (preferably GET if you want people to send a “vote up this image” link, preferably POST if you don’t want such links to be possible). This is easy, but it also requires reloading the page which is why modern voting systems use AJAX calls (javascript).

    Your HTML form would look something like this:

    <!-- Person A goes here -->
    This person has a score of <!-- We'll do this soon -->.
    
    <form method="get" <!-- or post --> action="vote.php">
    <input type="submit" name="submit_button" value="Vote Up!" />
    <input type="submit" name="submit_button" value="Vote Down =(" />
    <input type="hidden" name="person" value="A" />
    </form>
    
    <!-- Similar for person B -->
    

    Note that <!-- --> is the syntax for an HTML comment (these will be removed in the final website)

    In vote.php you would need to first see if the form was submitted, then see WHICH submit button was pressed (vote up or down), then see which person it applies to. Then we do our database entry.

    <?php
        if(isset($_GET['submit_button'])){
            // They submit the form
    
            $add = ($_GET['submit_button'] == 'Vote Up!') ? 1 : -1;
    
            $person = $_GET['person'];
    
            $link = mysql_connect('localhost', 'user', 'password');
            mysql_select_db('database', $link);
            mysql_query("UPDATE table SET value=value+$add WHERE person=$person");
        } else {
            die("You didn't submit the form =(");
        }
    ?>
    

    Mind you this is a REALLY dirty method (there is no parsing of the query and no checks made. This is very susceptible to an SQL injection. Do NOT use this in a database with important information. In fact- probably don’t use this at all without a few changes =) )

    Now then, this basically takes the table table, finds the entry where person equals whatever person was selected (chosen by which form was used to submit), then adds either +1 or -1 to value. You can change any of these variable names in your own table. The next step: reading the value to display on the previous page. Remember that before I just had the comment <!-- we'll do this soon -->. We’ll get to that now.

    In the beginning of your first page you want to read the database. This means your first page must also be PHP.

    <?php
        $link = mysql_connect('localhost', 'user', 'password');
        mysql_select_db('database', $link);
        $result = mysql_query("SELECT value FROM table WHERE person=A");
        ...
    

    Now you have a MySQL resource, but you need the value out of it.

        ...
        $row = mysql_fetch_row($result);
        ...
    

    And now we display it with the information.

    <!-- Person A goes here -->
    This person has a score of <?php echo $row[0]; ?>.
    
    <form method="get" <!-- or post --> action="vote.php">
    <input type="submit" name="submit_button" value="Vote Up!" />
    <input type="submit" name="submit_button" value="Vote Down =(" />
    <input type="hidden" name="person" value="A" />
    </form>
    

    Then you repeat for person B. This is really the dirtiest method since it involves one call to the database per person. Ideally you’d grab all values you want in a single call and then iterate over the returned resource and determine who was who. Or, if you really wanted to be fancy, you could already know who was who by using SORT ASC =)

    Like I said, though, this is the quickest, easiest, and dirtiest method to do what you want using PHP and MySQL.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.