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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:42:35+00:00 2026-05-28T15:42:35+00:00

I am trying to figure out how to retrieve data from a MySQL database

  • 0

I am trying to figure out how to retrieve data from a MySQL database using an AJAX call to a PHP page. I have been following this tutorial

http://www.ryancoughlin.com/2008/11/04/use-jquery-to-submit-form/

But i cant figure out how to get it to send back json data so that i can read it.

Right now I have something like this:

$('h1').click(function() {
            $.ajax({
                type:"POST",
                url: "ajax.php",
                data: "code="+ code,
                datatype: "xml",
                success: function() {

                $(xml).find('site').each(function(){
                    //do something
                });
            });


        });

My PHP i guess will be something like this

    <?php

    include ("../../inc/config.inc.php");

    // CLIENT INFORMATION

    $code        = htmlspecialchars(trim($_POST['lname']));

    $addClient  = "select * from news where code=$code";
    mysql_query($addClient) or die(mysql_error());

?>

This tutorial only shows how to insert data into a table but i need to read data. Can anyone point me in a good direction?

Thanks,

Craig

  • 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-05-28T15:42:36+00:00Added an answer on May 28, 2026 at 3:42 pm

    It’s nothing different. Just do your stuff for fetching data in ajax.php as usually we do. and send response in your container on page.

    like explained here :

    http://openenergymonitor.org/emon/node/107

    http://www.electrictoolbox.com/json-data-jquery-php-mysql/

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

Sidebar

Related Questions

I'm trying to figure out the safest way to retrieve unicode data in a
I am trying to retrive data to my SL application from PHP, MySQL service
I'm stuck with retrieving data from a MySQL-database in an efficient way. I have
Trying to figure out an equation to get the current group a page would
I'm trying to figure out the correct way to create an AsyncTask to retrieve
I'm trying to retrieve a page with greasemonkey and then extract a link from
I'm trying to connect to an MSAccess database and retrieve some data. With simple
I'm trying to figure out the a way to get extra data to be
I was trying to retrieve some JSON data from Google's AppEngine, and also a
I've been trying to figure this out for a while, and I just can't.

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.