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 8175131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:39:35+00:00 2026-06-06T22:39:35+00:00

I need help with one ajax function This is raw page setup. Page will

  • 0

I need help with one ajax function

This is raw page setup.
Page will contain table with links in this form

….
link – button1 – button2
link – button1 – button2
link – button1 – button2
…

where button1 is for hiding of row, and button2 is for hiding + adds+1 value to that link in db. every link will have unique id that will go with button2, so it would be easy to target it.
So , visitor would click on one of button in a row, row will hide, then he moves to another row….

DB setup:

id – link – …. – nmbOFlikes

My problem is that I dont know Ajax, and it is only solution to update db without need to refresh after every button click.

That page is not static, it is formated by another function that draws data from db
This is simple html page version, so if anyone could help…

So this is javascript without function

$(document).ready(function(){
    $("button.live").click(function(){
    $(this).parents('tr').hide();
        alert('Link is hidden');
    });
$("button.add").click(function(){
  $(this).parents('tr').hide();
  alert('This link is dead');
  $.post("update_db.php", { id: button_id, increment: true },
   function(data) {
   alert("Link incremented");
 });

});
});

And this is table

<table width="500" border="0" cellspacing="0" cellpadding="3">
    <tr>
        <td><p>Link 1</p></td>
        <td><button class="live">live</button></td>
        <td><button class="add" id="1">add</button></td>
    </tr>
    <tr>
        <td><p>Link 2</p></td>
        <td><button class="live">live</button></td>
        <td><button class="add" id="2">add</button></td>
    </tr>
</table>
  • 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-06-06T22:39:37+00:00Added an answer on June 6, 2026 at 10:39 pm

    You wouldn’t add the value directly to the database, you will post the data to a script first. I’m not completely clear on what your trying to accomplish but the post function may look something like:

    $.post("update_database_with_ajax.php", { id: button_id, increment: true },
       function(data) {
         alert("Link incremented");
       });
    

    Here is a functional jsFiddle example: Jquery POST Example

    update_data_With_ajax.php

    /** This is an example and should not be used 'as is' **/
    if ( isset( $_REQUEST['increment'] ) {
    
        // Connect to MySQL
        $conn = mysql_connect("localhost", "root", "");
    
        if (!$conn) {
            die('Could not connect: ' . mysql_error());
        }
    
        // Fetch the values we posted using AJAX
        $id = mysql_real_escape_string( $_REQUEST['id'] );
    
        //Select your database
        mysql_select_db("my_db", $conn);
    
        //increment your number of clicks    
        mysql_query("UPDATE table_name SET nmbofclicks = nmbofclicks + 1 WHERE id = {$id}");
    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really need help on this one. I am having a simple login form
I need your help with this one again. I want to send special characters
We Really need some help on this one: We've Struggled with all the Apple
Okay, I need help. I'm usually pretty good at SQL queries but this one
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
I desperately need some help on this one. I've created a <script> that closely
We are using Linq-to-SQL with stored Procedures we need help on one of our
I need help extending a functional update query that performs calculations on one record
I need some help dealing with three Threads in Android One thread is the
Need some help, please. I have a line of horizontal thumbnails loaded as ONE

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.