Jump to content
WebFlake

MySQL + PHP (+ Ajax) | Help


BasS™

Recommended Posts

Hello,

i want to know how to make a button. When i click on it, it instert's a extra emty row in MySQL Table, it should to be used PHP and/or Ajax scripts.. I Searched for it on the internet, no luck.. :/

i tried to instert like this PHP code

include("connect.php");
if (mysql_query("INSERT INTO `list` (`id`, `name`, `from`, `birthdate`, `job`) VALUES ('$id', 'Name', 'From', 'Birthdate', 'job');")) {
    echo "success";}

but how to make a button ? Sorry, i'm only beginner on PHP, MySQL..

Thanks :x

Link to comment
Share on other sites

  • 9 months later...

Just gonna leave this here if anyone needs the AJAX implementation using JQuery.

HTML:

<button id="my_button">Click Me</button>

JS:

$("#my_button").click(function(){
    $.ajax({url: "/path/to/connect.php", success: function(result){
        alert("The result is:" + result);
    }});
});

After you clicked it and the query you made in the connect.php file, it should popup a message saying "success" or in case of failure nothing will happen.

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...