Preparing and selecting received content from mysql DB

Hi.....again.

I have been working with the mysql tutorial and have the communication and database side working fine (it's great) however I am really struggling to work with the data that is received from the Web.GotText 'response content'
I've been meesing with every combination of list block to transform the data into something i can select with an index system (or any way of navigating the table data)
One of the first jobs was to populate a listpicker but have the element name made up of a few columns from the database like job number, site number, location so that would be displayed in the lp elements. (picture attached) the picture is almost what i was aiming for but i wanted to join some text strings in between the data for a prefix e.g. "Location: " [data] "- " "Job No" [data] etc
I cannot find a way of breaking out the response to do this.

Blocks attached

I hope that doesn't sound too messy.

Do not assign a table (list of lists) into a ListView Elements, otherwise you will get an ugly default conversion. Assign the table into a global variable (after csv conversion, so you can loop through its rows with a for each block.

set global dataTable to csv_to_table (web responsecontent)
set global **formatted_list** to create empty list
for each row in global dataTable
   set local variable ROWID to select item 1 from row
   set local variable JobNo to select item 2 from row
   set local variable Location to select item 3 from row
   set local variable SiteNo to select item 4 from row
   set local bigJoin to JOIN("Location: ", Location, "- ", "Job No: ", JobNo,  ...)  *
   add item bigJoin to list global **formatted_list**
end for each
set ListView.Elements to global **formatted_list**
  • (use the blue button to add sockets as needed)

Hi, I'm trying to follow your reply and while i can see it makes sense I just cant get the hang of the local variables and parsing values around in the blocks system.

This is where im going with your instructions for a quick example.
If i could just access the datatable entries like a grid system thats great for me like a 2D array

I'll keep trying.

Are there any good tutorials for handling list data?
I've looked and most things point to the ai2 blocks info page or gives simple examples of make a list block and select an index.
The blocks are killing me!

Learn about using lists:

General Tutorials

Here are some SQL-like app samples that use value procedures to filter tables ...
https://groups.google.com/d/msg/mitappinventortest/656oDTQeomU/7-WNXaxBGwAJ

Thank you for the links

Ah that looks to be just the job. I think i need to take a step back and do some reading to get this method straight in my head. I'll have a good look later. Thanks for the help.

I've tried everything to get this simple task to work in appinventor and i'm really out of ideas.
I dont need anything fancy, its just taking a web response and making a workable list out of it. I can make ways to use the list on my own, if i can just get to the point of having a list that works. Please save me from this infuriating problem.

As you have shown it, you are returning a single csv row of 124/125 items, there are no line returns after each four items to make it a table.

You can split this into a list of 124/125 items, then with a counter and some logic, put it back together as rows of four to make your table/list.

Export your .aia file and upload it here.

Here is my way, someone might come along with a better solution:

splitToTable.aia (3.1 KB)

image

1 Like

Okay, I've had some good results....finally
See the blocks picture, one way or another I was able to use the prepared list to select from with an index. I now have the listpicker elements set with multiple items of data and the coded prefixes, all taken from the mysql database. Now i'll just do the exact same thing but with all the columns of my database and use that to populate the rest of the app (after the listpicker selection.)
I could try and do a little tutoral on this make it more available. personally i didn't find a simpler way to do it. explaining the requirement is half the battle. Thanks for you assistance once again.


Hi Thanks for your responses I replied to ABG with my conclusion.

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