Using Jquery Ajax to retrieve data from Mysql

0 votes

list.php: A simple ajax code that I want to display only records of the Mysql table:

<html>

<head>
    <script src="jquery-1.9.1.min.js">
    </script>
    <script>
    (document).ready(function() {
        var response = '';
        .ajax({
            type: "GET",
            url: "Records.php",
            async: false,
            success: function(text) {
                response = text;
            }
        });

        alert(response);
    });
    </script>
</head>

<body>
    <div id="div1">
        <h2>Let jQuery AJAX Change This Text</h2>
    </div>
    <button>Get Records</button>
</body>

</html>

Records.php is the file to fetch records from Mysql.
In the Database are only two fields: 'Name', 'Address'.

<?php
    //database name = "simple_ajax"
    //table name = "users"
    con = mysql_connect("localhost","root","");
    dbs = mysql_select_db("simple_ajax",con);
    result= mysql_query("select * from users");
    array = mysql_fetch_row(result);
?>
<tr>
    <td>Name: </td>
    <td>Address: </td>
</tr>
<?php
    while (row = mysql_fetch_array(result))
    {
        echo "<tr>";
        echo "<td>row[1]</td>";
        echo "<td>row[2]</td>";
        echo "</tr>";
    }   
?>

This code is not working. Can someone please help me fix this?

Jun 20, 2022 in PHP by Kithuzzz
• 38,010 points
733 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
3,016 views
0 votes
0 answers

How to retrieve data from multiple tables using a PHP form?

I want to retrieve data from multiple ...READ MORE

Jun 25, 2022 in PHP by narikkadan
• 63,420 points
1,561 views
0 votes
0 answers

How can I store and retrieve images from a MySQL database using PHP?

How can I insert an image in ...READ MORE

Jun 14, 2022 in PHP by narikkadan
• 63,420 points
359 views
0 votes
0 answers

How to retrieve images from MySQL database and display in an html tag

I created a table using the  BLOB column ...READ MORE

Jun 19, 2022 in PHP by narikkadan
• 63,420 points
1,253 views
0 votes
0 answers

How to filter data from a MySQL Database Table with PHP

I'm attempting to code a search box ...READ MORE

Jul 22, 2022 in PHP by narikkadan
• 63,420 points
5,872 views
0 votes
0 answers

How to fetch specific data from MySQL database to my PHP table?

I want to get data from the ...READ MORE

Jul 28, 2022 in PHP by Kithuzzz
• 38,010 points
2,742 views
0 votes
0 answers

Edit PHP query code depending on image map clicked area using AJAX

I am working on an image map ...READ MORE

Jun 3, 2022 in PHP by Kichu
• 19,050 points
275 views
0 votes
1 answer

Using Jquery Ajax to retrieve data from Mysql

Perform a AJAX GET request to get ...READ MORE

answered Jun 23, 2022 in Web Development by rajatha
• 7,640 points
22,118 views
0 votes
0 answers

How to run a PHP function due to a button click (with button 'data' passed)?

I manage some sortiment items on a ...READ MORE

May 28, 2022 in PHP by Kichu
• 19,050 points
3,549 views
0 votes
1 answer

Convert Excel's "41014" date to actual date in PHP or JavaScript

PHPExcel Date handling code: public static function ExcelToPHP($dateValue ...READ MORE

answered Oct 24, 2022 in Others by narikkadan
• 63,420 points
3,396 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP