how to retrieve data from database and display it in textboxes using javascript?

Today, We want to share with you how to retrieve data from database and display it in textboxes using javascript.In this post we will show you how to display data from database in html table using javascript, hear for how to fetch data from database in php and display in textbox before editing we will give you demo and example for implement.In this post, we will learn about how to retrieve data from database in html form with an example.

Read Also:  how to fetch data from database in php using search button?

how to fetch data from database in php using search button?

register.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Member registion</title>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script>

        $(function () {
            $('#btn').click(function () {
              $.post(
                  'checkMemberName.php',{
                      membername:$('#membername').val()
                  },function(data,textStatus){
                      $('#outputs').html(data);
                });
            });
        });

    </script>
</head>
<body>
    <h2>Member registion</h2>
    <form action="" method="post">
        memberName:<input type="text" name="membername" id="membername">
        <input type="button" value="Verify memberName" id="btn">
        <br>
        <span id="outputs"></span>


    </form>
</body>
</html>

checkMemberName.php

<?php

$membernm = $_POST['membername'];

$conn = mysqli_connect('localhost','root','root','db_member');
$query = "SELECT * from tb_member where name = '$membernm' ";
$outputs = mysqli_query($conn,$query);
$nums = mysqli_num_rows($outputs);

//echo $query;
//echo $nums;
if($nums > 0){
    echo "Membername already exist";
}else{
    echo "Membername OK";
}

mysqli_close($conn);

I hope you get an idea about how to fetch data from database in php using ajax with example.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  Make Bootstrap 3 Dynamic Tabs Responsive Example

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *