Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON - Returning JSON to a input jqGrid autocomplete
    primarykey
    data
    text
    <p>I need help in this thing: I'm doing a autocomplete in a jqGrid, and what I need to do is to return JSON to the input of autocomplete. I'm doing something like this, but in my autocomplete just return one value and in the database I have more than one. Somebody could help me in this. I'm doing the return like this:</p> <pre><code>... header("Content-Type: application/json"); $i=0; while($row = pg_fetch_array($result)) { $response-&gt;input['value']=$row[ac_fin_g]; $i++; } echo json_encode($response); ... </code></pre> <p>But for example.. I have in the database the values for ac_fin_g: {house, home, cake}. If I write the letter "O", the correct to appear is "HOUSE" and "HOME" in my autocomplete, but this is not happening. When I change the code above for this code (for the input="HO"):</p> <pre><code>... header("Content-Type: application/json"); $i=0; while($row = pg_fetch_array($result)) { $response-&gt;input[$i]['value']=$row[ac_fin_g]; $i++; } echo json_encode($response); ... </code></pre> <p>I have the correct JSON:</p> <pre><code>{"input":[{"value":"HOME "},{"value":"HOUSE "}]} </code></pre> <p>I'm sorry but I don't know how to fix this. Somebody could help me?</p> <hr> <p><strong>UPDATE:</strong> Thanks to @Oleg I figured out how to do this. For my case is:</p> <pre><code>$i=0; while($row = pg_fetch_array($result)) { $response[] = $row[ac_fin_g]; $i++; } echo json_encode($response); </code></pre> <p>:)</p> <p>PS: This <a href="https://stackoverflow.com/questions/1830264/how-can-i-convert-the-result-of-this-postgres-db-query-into-json-to-return-to-my">link</a> can be useful :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload