I am not sure how to write the following code.
$rowID = $_POST['rowID'];
if ($listing = $Listings->getData($rowID)) {
$jsonArray = array(
'listing_number' => $listing['listing_number'],
);
exit(json_encode($jsonArray));
}
When I do it like that, the response is Undefined Index: listing_number.
However, If I write it like this,
$rowID = $_POST['rowID'];
if ($listing = $Listings->getData($rowID)) {
$jsonArray = array(
'listing_number' => $listing[0],
);
exit(json_encode($jsonArray));
}
The response is
{"listing_number":{"id":"24","client_id":"1","address":"","address_2":"","city":"","state":"","zip":"","price":"","listing_number":"asdasdasdasd","remarks":"","link":"","status":"","bd":"","ba":"","lot_sz":"","sq_ft":"","yr":"","type":"","thumb":""}}
Which lets me know my SQL is and PHP is correct, I just don't know how to access $listing['listing_number] correctly.
Any help would be appreciated.
$listing[0]['listing_number']edit: You said it's an stdClass, so you need to use$listing[0]->listing_number$listing = $Listings->getData($rowID)this data may be array and therefore getting index0will give you 1 record. Then you can get"listing_number"of that data.$listing[0]->listing_number