JsonList problem with json, php, mysql

Hello, I have a problem with the visualization of the data … I do a simple reading of the mysql database, but the data in the listview is not visluazzati correctly … there is some problem with json and php: where am I wrong?

Name: Luca
Email: l@tin.it
Address: aaa

Wrong (My):
Name:[“name”, “Luca”]
Email:[“email”, “l@tin.it”]

help me please!!!



<? header('Content-Type: application/json; charset=utf-8'); require_once __DIR__ . '/src/JsonMapper.php'; $host = "myIp"; $user = "myUser"; $pass = "MyPass"; $db = "myDb"; // Create connection $conn = mysqli_connect($host, $user, $pass, $db); // Check connection $q = mysqli_query($conn, "SELECT * FROM test"); $json = array(); while($data = mysqli_fetch_assoc($q)) array_push($json, array('name' => $data['name_user'], 'email' => $data['email_user'], 'address' => $data['address_user'])); echo json_encode(array('users' => $json)); mysqli_close($conn); ?>

When you decode JSON text, the output is a list or dictionary structure that you can feed into a lookup in pairs block or a dict block to lookup by tag.

Using text replace on list or dict structures completely misses the point of having the name:value pairs.
See FAQ Section: JSON and Dictionaries

Inanzitutto grazie per la risposta. Sono alle prime armi con app inventor.
Quindi se ho capito bene devo usare combinazione del blocco JsonTextDecode del componente Web e dei blocchi elenco è possibile accedere a qualsiasi record di dati di immissione e valore tag?
Se è così, quale blocco dovrei modificare?

First of all thanks for the reply. I am a beginner with app inventor.
So if I understand correctly I have to use a combination of the block JsonTextDecode of the Web component and block list, you can access any data record input tag value?
If so, what block should I change?

Export your .aia file and post it here.
We can’t fix blocks that we don’t have.

jsonList.aia (526.7 KB)

Here’s the raw Json you receive (from a Do It, so extra quotes) …
“{“users”:[{“name”:“Luca”,“email”:“prova@tin.it”,“address”:“viale san giuseppe”},{“name”:“Dona”,“email”:“dona@hotmail.it”,“address”:“Regione Muda”}]}”

It’s a JSON text of an object, single attribute (tag = “users”, value = list of user objects.)

Here’s how to parse it …
global users global responseContent

Here’s how it looks …

If you want to retrieve values from a ListView selection to populate Labels, use the .SelectionIndex and look up the values by index in global users, then by tag name in the selected user item.

All blocks are draggable, so no need to retype.

ok, after I try and let you know

Great, it works !!
One more question: if I wanted to click on a data (for example the name), would it be better to stay on the Listview or is it better a text or button field?

Try both. See what works for you.

ok, thanks for everything

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.