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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:05:02+00:00 2026-06-04T05:05:02+00:00

I can send a query to mysql database with following code: $sql = mysql_query(INSERT

  • 0

I can send a query to mysql database with following code:

$sql = mysql_query("INSERT INTO wall VALUES('', '$message', '$replyno')");

My questions is, Is there any way to send a query with just a click on some text.

Let’s example: there are a text name Reply. I want if i click this Reply text then mysql database field value (field name: Reply, type: int) will be increase by 1.

Sorry I DON’T KNOW ABOUT JAVASCRIPT/AJAX:(

FINAL UPDATER CODE TO @DEVELOPER:

<html>
<head>
<title>Untitled Document</title>
</head>
<script language="javascript">
$("#mylink").click(function() {
$.ajax({
url: "test.php"
}).done(function() { 
$(this).addClass("done");
});
});
</script>
<body>
echo "<a href='#' id='mylink'>Reply</a>";
</body>
</html>
Php page:
<?php
include("database/db.php");
$sql = mysql_query("INSERT INTO wall VALUES('','','','','','','','1');");
?>
  • 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-04T05:05:03+00:00Added an answer on June 4, 2026 at 5:05 am

    You should have this link or button to be clicked wired to an ajax call using jQuery

    http://api.jquery.com/jQuery.ajax/

    It should call a php page, which contains the query you’re looking to run. You can pass in arguments with the ajax call as well, so that your $message and $replyno are set properly before executing.

    <script>
    $("#mylink").click(function() {
      $data = $("#myform").serialize();
      $.ajax({
        url: "postquery.php",
        data: $data
      }).done(function() { 
         $(this).addClass("done");
      });
    });
    </script>
    

    then your php page would look something like this:

    <?php
    ...
    $message = mysql_real_escape_string($_REQUEST['message']);
    $replyno = mysql_real_escape_string($_REQUEST['replyno']);
    $sql = mysql_query("INSERT INTO wall VALUES('', '$message', '$replyno')");
    ....
    ?>
    

    Excaping your incoming strings using “mysql_real_escape_string” is always important to prevent SQL Injection attacks on your database.

    Your HTML should look something like this:

    <html>
    ...
    <input type="textarea"></input>
    <a href="#" id="mylink">Reply</a>
    ...
    </html>
    

    This will cause the previously stated jquery statement to trigger when “Reply” is clicked.

    Here is with your updated code. I corrected the link ID and also removed the form serialization data since your test code does not appear to need it. I also added the reference to the jQuery library:

    <html>
    <head>
    <title>Untitled Document</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script language="javascript">
    $("#mylink").click(function() {
      $.ajax({
        url: "test.php"
      }).done(function() { 
         $(this).addClass("done");
      });
    });
    </script>
    </head>
    <body>
    <a href='#' id='mylink'>Reply</a>
    </body>
    </html>
    

    The problems you’re likely seeing are because of your query, not the front end code. Try adding some debug code like this:

    <?php
    include("database/db.php");
    $sql = mysql_query("INSERT INTO wall VALUES('','','','','','','','1');");
    if(!$sql)
    {
      echo mysql_error();
    }
    ?>
    

    Or try checking your servers error logs.

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

Sidebar

Related Questions

Suppose you're typing a command line query into a MySQL database and you need
In Javascript I can send XML string to JSP server (XmlAction.jsp): Javascript Code: var
I want to create a backup of my mysql database that's created in Query
I am using node.js to query a MySQL database table every 10 seconds. Using
I can send newsletters to email accounts. I am using div for containing the
I can send any windows application key strokes with PostMessage api. But I can't
I can send requests to friends using Multi Friend Request Selector inside my Page
If webserver can send gzip response, why can't browser sent gzip request?
how i can send key from my C# program to external program ? ex:
how i can send sms from asp.net?any idea about it?or any resource through which

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.