0

Hi I am developing an app in phonegap, where I am getting a particular value from server by connecting php file the value I need to pass is a string value 'pmnno'suppose whose value is '2' I need to get the value of '2' in column name 'personalnumber'.. So I am giving my code below

var jsonData;
$.ajax({ 
    type: 'GET', 
    url: 'http://xxxx.com/app/get_pday1_number.php', 
    data: { pmnno: '2' }, 
    dataType: 'html',
    success: function (response) { 
jsonData = response;
        alert(jsonData);

    }
});

php code

<?php

// array for JSON response   
$response = array();    
    // include db connect class
    require_once __DIR__ . '/db_connect.php';       

    // connecting to db
    $db = new DB_CONNECT();        

    // check for post data
    if (isset($_GET["pone"])) 

    {
        $pone = $_GET['pone'];           

        // get a product from products table
        $result = mysql_query("SELECT *FROM pdaynew WHERE pone = $pone");

        if (!empty($result)) {
            // check for empty result
            if (mysql_num_rows($result) > 0) {

                $result = mysql_fetch_array($result);

                $product = array();
                $product["pid"] = $result["pid"];                    
                $product["pone"] = $result["pone"];                    
                $product["personaldayone"] = $result["personaldayone"];
                $product["created_at"] = $result["created_at"];
                $product["updated_at"] = $result["updated_at"];                   

                // success
                $response["success"] = 1;         
                // user node
                $response["product"] = array();         
                array_push($response["product"], $product);         
                // echoing JSON response
                echo json_encode($response);
            } else {
                // no product found
                $response["success"] = 0;
                $response["message"] = "No product found";

                // echo no users JSON
                echo json_encode($response);
            }
        } else {
            // no product found
            $response["success"] = 0;
            $response["message"] = "No product found";

            // echo no users JSON
            echo json_encode($response);
        }
    } else {
        // required field is missing
        $response["success"] = 0;
        $response["message"] = "Required field(s) is missing";

        // echoing JSON response
        echo json_encode($response);
    }
    ?>

I am getting a success mesage that means connection is succesful but ineed the value of '2' in column 'personalnumber' for that where I need to add that code..If anyone knows pls help me...

14
  • It's a bit unclear what you're asking, specifically what is the "column" you're talking about. Perhaps add the relevant HTML and an example of the desired outcome? Commented Mar 23, 2015 at 11:53
  • plz show the code of get_pday1_number.php Commented Mar 23, 2015 at 11:55
  • that means in my table where this php is connecting there is 4 columns are there first is number where 1-10 is there then description for that each numbers that is next column... so if value is 9 i need to get the description for 9 in the next column Commented Mar 23, 2015 at 11:56
  • @proyank please check I gave the php code Commented Mar 23, 2015 at 11:58
  • @Jocheved where are you getting "pmnno" value in get_pday1_number.php Commented Mar 23, 2015 at 12:00

1 Answer 1

1

Instead of using * use personaldayone:

$result = mysql_query("SELECT personaldayone FROM pdaynew WHERE pone = $pone");
Sign up to request clarification or add additional context in comments.

2 Comments

@Jocheved please upvote & accept.if my answer is useful for you.
It is working.. but {"success = 1,"product":[{" pone":null,"personaldayone":" Here I am getting the result"}]}... but I dont want these brackets and success and pone... only personaldayone value is needed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.