Multiple values from the result

prasad.mhatre's Avatar

prasad.mhatre

09 Nov, 2014 09:48 AM

Dear All,

I have this code working with database.

My table consist of 3 fields
viz.
id abvr name rate_normal

I am able to get only one field 'name' is posted to the next page. Is it possible to get all the values or atleast one more field 'rate_normal' posted to next page?

How do I do that?

My code goes like this:
$query = sprintf("SELECT id, abvr, name, rate_normal from pat_titles3 WHERE abvr LIKE '%%%s%%' ", mysql_real_escape_string($_GET["q"]));
$arr = array();
$rs = mysql_query($query);

# Collect the results
while($obj = mysql_fetch_object($rs)) {
    $arr[] = $obj;

}

# JSON-encode the response
$json_response = json_encode($arr);

# Optionally: Wrap the response in a callback function for JSONP cross-domain support
if($_GET["callback"]) {
    $json_response = $_GET["callback"] . "(" . $json_response . ")";
}

# Return the response
echo json_encode($arr);

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac